|
View:
New views
16 Messages
—
Rating Filter:
Alert me
|
|
|
Preview button to show PDF without submitting post data?PHP Users,
I have a page that generates a PDF document using PHP. It takes form data filled in by the user to fill out the PDF When the user clicks "submit", it emails that PDF document to the intended recipient. However, I would like to add a "preview" function as well. But for a variety of reasons, instead of submitting the form data through post and re-filling all the fields with the selected data, I'd like to be able to open a new window with an example PDF without actually submitting the form. I think this might need JavaScript, but I'm not sure. Is this possible? Thank you for any advice. -- Dave M G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Preview button to show PDF without submitting post data?You could just open in a new window a php script that generates the "preview" pdf with a content-type header for pdf.
header("Content-type: application/pdf"); Or if the "preview" pdf is not dinamic, just point the url to the pdf. No javascript needed, just a link, o a submit button on a form with the url as the "action" attribute. If you need it to open on a new window, use target="_blank", or better target="pdf" if you want consecutive requests to open in the same window instead of a new one everytime. Note: if you are not using transitional html and care about validation, the target attribute is not allowed. In that case you would need javascript to open a new window. ________________________________ De: Dave M G <martin@...> Para: PHP-General List <php-general@...> Enviado: vie,6 noviembre, 2009 04:58 Asunto: [PHP] Preview button to show PDF without submitting post data? PHP Users, I have a page that generates a PDF document using PHP. It takes form data filled in by the user to fill out the PDF When the user clicks "submit", it emails that PDF document to the intended recipient. However, I would like to add a "preview" function as well. But for a variety of reasons, instead of submitting the form data through post and re-filling all the fields with the selected data, I'd like to be able to open a new window with an example PDF without actually submitting the form. I think this might need JavaScript, but I'm not sure. Is this possible? Thank you for any advice. -- Dave M G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Preview button to show PDF without submitting post data?My question is slightly the same:
how can I print a dynamically generated text file without opening a new window, or navigating from the current one? Thanks, SanTa ----- Original Message ----- From: "Fernando Castillo Aparicio" <f_c_a_1980@...> To: "Dave M G" <martin@...>; "PHP-General List" <php-general@...> Sent: Friday, November 06, 2009 8:37 AM Subject: Re: [PHP] Preview button to show PDF without submitting post data? You could just open in a new window a php script that generates the "preview" pdf with a content-type header for pdf. header("Content-type: application/pdf"); Or if the "preview" pdf is not dinamic, just point the url to the pdf. No javascript needed, just a link, o a submit button on a form with the url as the "action" attribute. If you need it to open on a new window, use target="_blank", or better target="pdf" if you want consecutive requests to open in the same window instead of a new one everytime. Note: if you are not using transitional html and care about validation, the target attribute is not allowed. In that case you would need javascript to open a new window. ________________________________ De: Dave M G <martin@...> Para: PHP-General List <php-general@...> Enviado: vie,6 noviembre, 2009 04:58 Asunto: [PHP] Preview button to show PDF without submitting post data? PHP Users, I have a page that generates a PDF document using PHP. It takes form data filled in by the user to fill out the PDF When the user clicks "submit", it emails that PDF document to the intended recipient. However, I would like to add a "preview" function as well. But for a variety of reasons, instead of submitting the form data through post and re-filling all the fields with the selected data, I'd like to be able to open a new window with an example PDF without actually submitting the form. I think this might need JavaScript, but I'm not sure. Is this possible? Thank you for any advice. -- Dave M G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Preview button to show PDF without submitting post data?On Fri, 2009-11-06 at 12:11 +0100, Sándor Tamás (HostWare Kft.) wrote:
> My question is slightly the same: > how can I print a dynamically generated text file without opening a new > window, or navigating from the current one? > > Thanks, > SanTa > > ----- Original Message ----- > From: "Fernando Castillo Aparicio" <f_c_a_1980@...> > To: "Dave M G" <martin@...>; "PHP-General List" > <php-general@...> > Sent: Friday, November 06, 2009 8:37 AM > Subject: Re: [PHP] Preview button to show PDF without submitting post data? > > > You could just open in a new window a php script that generates the > "preview" pdf with a content-type header for pdf. > > header("Content-type: application/pdf"); > > Or if the "preview" pdf is not dinamic, just point the url to the pdf. > > No javascript needed, just a link, o a submit button on a form with the > url as the "action" attribute. If you need it to open on a new window, > use target="_blank", or better target="pdf" if you want consecutive > requests to open in the same window instead of a new one everytime. > > Note: if you are not using transitional html and care about validation, the > target attribute is not allowed. In that case you would need javascript to > open a new window. > > > > > ________________________________ > De: Dave M G <martin@...> > Para: PHP-General List <php-general@...> > Enviado: vie,6 noviembre, 2009 04:58 > Asunto: [PHP] Preview button to show PDF without submitting post data? > > PHP Users, > > I have a page that generates a PDF document using PHP. It takes form > data filled in by the user to fill out the PDF > > When the user clicks "submit", it emails that PDF document to the > intended recipient. > > However, I would like to add a "preview" function as well. But for a > variety of reasons, instead of submitting the form data through post and > re-filling all the fields with the selected data, I'd like to be able to > open a new window with an example PDF without actually submitting the form. > > I think this might need JavaScript, but I'm not sure. > > Is this possible? > > Thank you for any advice. > > -- > Dave M G > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > > Print it where? Thanks, Ash http://www.ashleysheridan.co.uk |
|
|
|
|
|
|
|
|
Re: Preview button to show PDF without submitting post data?On Fri, Nov 06, 2009 at 12:11:44PM +0100, Sándor Tamás (HostWare Kft.) wrote:
> My question is slightly the same: > how can I print a dynamically generated text file without opening a new > window, or navigating from the current one? > Generally speaking, browsers use a helper application (like Acrobat Reader or XPDF) to render a PDF. The helper application will have a print icon or some way to print the PDF. Even if the PDF is seemingly rendered by the browser itself (as sometimes happens in IE), there is still a printer icon available. If you *aren't* displaying the PDF, but only generating it, there isn't really a way to do this without javascript or something similar. The PDF is on the server, but printing will be on the client/browser. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Preview button to show PDF without submitting post data?Fernando,
Thank you for responding. > You could just open in a new window a php script that generates the "preview" pdf with a content-type header for pdf. Yes, but how would the form data be carried over to the new window? The thing is that I have all this form data that the user has entered, and before they submit it to be stored in the database, they want to see it in a PDF file. If I just point the link to a new script that generates the PDF, won't the form data be lost? Or is can I attach Post data to the new window? -- Dave M G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Preview button to show PDF without submitting post data?On Sat, 2009-11-07 at 14:59 +0900, Dave M G wrote:
> Fernando, > > Thank you for responding. > > > You could just open in a new window a php script that generates the "preview" pdf with a content-type header for pdf. > > Yes, but how would the form data be carried over to the new window? > > The thing is that I have all this form data that the user has entered, > and before they submit it to be stored in the database, they want to see > it in a PDF file. > > If I just point the link to a new script that generates the PDF, won't > the form data be lost? > > Or is can I attach Post data to the new window? > > -- > Dave M G > The form data doesn't have to be lost. You can post it to an intermediate script that creates the PDF and holds the data. You could use Javascript to change the original form slightly so that it opens in a new window (set a target attribute) and then remove it immediately after. There are quite a few ways you can do all of this. Thanks, Ash http://www.ashleysheridan.co.uk |
|
|
Re: Preview button to show PDF without submitting post data?Dave M G schrieb:
> PHP Users, > > I have a page that generates a PDF document using PHP. It takes form > data filled in by the user to fill out the PDF > > When the user clicks "submit", it emails that PDF document to the > intended recipient. > > However, I would like to add a "preview" function as well. But for a > variety of reasons, instead of submitting the form data through post and > re-filling all the fields with the selected data, I'd like to be able to > open a new window with an example PDF without actually submitting the form. > > I think this might need JavaScript, but I'm not sure. > > Is this possible? > > Thank you for any advice. > to get the PDF you use a create PDF Engine writing on PHP right?. The Only Way to generate the PDF is, to get the Information from user (with the POST or GET method) using the PDF Engine writing on PHP right? I think you can generate the PDF and show it like a "preview" Page, but the User must be able to regenerate the PDF to send it as email (where the same Data will be used or not, please think about, if you want to do this) I think, you must to think more about the usability at this point Regards Carlos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Die Page, Die! (Was: Preview button to show PDF without submitting post data?)PHP List,
Okay, so I've got a nice situation where a form has a preview button as well as a submit button. When the user presses "Submit", the page reloads, and it emails a PDF. If the user presses "Preview", it launches a new page in a new window, and also outputs a PDF directly to the user so they can review it. All good, but I don't need that second window open once the PDF has been shown to the user. For some reason I can't kill that second window. I've tried two methods. Killing it with PHP, and killing it with JavaScript. Here's the PHP version: if (isset($_POST['preview'])) { $pdf->Output("preview.pdf", "D"); die("PDF プレビュー出しました / PDF Preview Displayed"); } Here's the JavaScript version: if (isset($_POST['preview'])) { $pdf->Output("preview.pdf", "D"); echo '<script type="text/javascript">javascript:self.close();</script>'; } But in either case, I keep getting that second page coming out, with the whole form rendered all over again. How can I kill a page? Once the PDF is rendered, I don't need it. I'd be okay if it came down to the browser then closed, but it would be better if the server sent the PDF and didn't send the page. Any advice would be much appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Die Page, Die! (Was: Preview button to show PDF without submitting post data?)On Sun, 2009-11-08 at 21:38 +0900, Dave M G wrote:
> PHP List, > > Okay, so I've got a nice situation where a form has a preview button as > well as a submit button. When the user presses "Submit", the page > reloads, and it emails a PDF. > > If the user presses "Preview", it launches a new page in a new window, > and also outputs a PDF directly to the user so they can review it. > > All good, but I don't need that second window open once the PDF has been > shown to the user. > > For some reason I can't kill that second window. I've tried two methods. > Killing it with PHP, and killing it with JavaScript. > > Here's the PHP version: > > if (isset($_POST['preview'])) > { > $pdf->Output("preview.pdf", "D"); > die("PDF プレビュー出しました / PDF Preview Displayed"); > } > > Here's the JavaScript version: > > if (isset($_POST['preview'])) > { > $pdf->Output("preview.pdf", "D"); > echo '<script type="text/javascript">javascript:self.close();</script>'; > } > > But in either case, I keep getting that second page coming out, with the > whole form rendered all over again. > > How can I kill a page? Once the PDF is rendered, I don't need it. I'd be > okay if it came down to the browser then closed, but it would be better > if the server sent the PDF and didn't send the page. > > Any advice would be much appreciated. I think you do, or where else would you show the PDF? Unless you force the PDF to download when the user clicks the preview button, you are left with the default option of the users browser, which will most usually be to display the PDF in the browser window. Thanks, Ash http://www.ashleysheridan.co.uk |
|
|
Re: Die Page, Die! (Was: Preview button to show PDF without submitting post data?)Ashley,
Thank you for responding. > I think you do, or where else would you show the PDF? Unless you force > the PDF to download when the user clicks the preview button, you are > left with the default option of the users browser, which will most > usually be to display the PDF in the browser window. No, that's not what's happening. I'm not showing the PDF in a browser window. It's being given to the user with the option to download or view in a separate application. So I am fine with the download option. That's what I'm doing now, I suppose. So since the user is downloading the PDF, they don't need an in-browser window to view it. Once the PDF is downloaded/viewed, I want the new window to die by any means necessary. Surely there's a way. -- Dave M G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Die Page, Die! (Was: Preview button to show PDF without submittingpost data?)Dave M G wrote:
> Ashley, > > Thank you for responding. > >> I think you do, or where else would you show the PDF? Unless you force >> the PDF to download when the user clicks the preview button, you are >> left with the default option of the users browser, which will most >> usually be to display the PDF in the browser window. > > No, that's not what's happening. I'm not showing the PDF in a browser > window. It's being given to the user with the option to download or view > in a separate application. > > So I am fine with the download option. That's what I'm doing now, I > suppose. So since the user is downloading the PDF, they don't need an > in-browser window to view it. > > Once the PDF is downloaded/viewed, I want the new window to die by any > means necessary. > > Surely there's a way. > yup.. forget the new window all together, if you have it set to download as an attachment then the user won't be taken away from the page; so no need for a new window at all. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Re: Die Page, Die! (Was: Preview button to show PDF without submittingpost data?)Nathan,
Thank you for responding. > yup.. forget the new window all together, if you have it set to download > as an attachment then the user won't be taken away from the page; so no > need for a new window at all. Right... so, we're all on board with the goals. Now... how do I do that? The whole problem here is that I keep getting a new window even though I don't want it. I would have thought if I told PHP to die immediately after outputting the PDF, it would give up on making the new window. I've also tried JavaScript to kill the window after it's made. *How* do I get the page to die? -- Dave M G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Re: Die Page, Die! (Was: Preview button to show PDF without submittingpost data?)On Nov 8, 2009, at 1:20 PM, Dave M G <martin@...> wrote: > Nathan, > > Thank you for responding. > >> yup.. forget the new window all together, if you have it set to >> download >> as an attachment then the user won't be taken away from the page; >> so no >> need for a new window at all. > > Right... so, we're all on board with the goals. > > Now... how do I do that? > > The whole problem here is that I keep getting a new window even > though I > don't want it. > > I would have thought if I told PHP to die immediately after outputting > the PDF, it would give up on making the new window. > > I've also tried JavaScript to kill the window after it's made. > > *How* do I get the page to die? > > -- > Dave M G > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > If you are popping up a new window just to handle the download, what about using a small iframe or hidden frame to handle that instead? Bastien -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
| Free embeddable forum powered by Nabble | Forum Help |