Preview button to show PDF without submitting post data?

Preview button to show PDF without submitting post data?

am 06.11.2009 04:58:15 von Dave M G

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?

am 06.11.2009 08:37:18 von Fernando Castillo Aparicio

--0-462439871-1257493038=:32637
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

You could just open in a new window a php script that generates the "previe=
w" pdf with a content-type header for pdf. header("Content-type: appli=
cation/pdf"); Or if the "preview" pdf is not dinamic, just point the u=
rl to the pdf. No javascript needed, just a link, o a submit button on=
a form with the=0Aurl as the "action" attribute. If you need it to open on=
a new window,=0Ause target=3D"_blank", or better target=3D"pdf" if you wan=
t consecutive=0Arequests to open in the same window instead of a new one ev=
erytime. Note: if you are not using transitional html and care about v=
alidation, the target attribute is not allowed. In that case you would need=
javascript to open a new window. =0A___________________________=
_____=0ADe: Dave M G =0APara: PHP-General List eneral@lists.php.net>=0AEnviado: vie,6 noviembre, 2009 04:58=0AAsunto: [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=
=0Adata filled in by the user to fill out the PDF When the user clicks=
"submit", it emails that PDF document to the=0Aintended recipient. Ho=
wever, I would like to add a "preview" function as well. But for a=0Avariet=
y of reasons, instead of submitting the form data through post and=0Are-fil=
ling all the fields with the selected data, I'd like to be able to=0Aopen 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. -- =0ADave M G -- =0APHP General=
Mailing List (http://www.php.net/)=0ATo unsubscribe, visit: http://www.php=
..net/unsub.php =0A
--0-462439871-1257493038=:32637--

Re: Preview button to show PDF without submitting post data?

am 06.11.2009 12:11:44 von sandortamas

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"
To: "Dave M G" ; "PHP-General List"

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
Para: PHP-General List
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?

am 06.11.2009 12:14:27 von Ashley Sheridan

--=-m9tL+PjkSv/XL3LOYEiy
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Fri, 2009-11-06 at 12:11 +0100, Sándor Tamás (HostWare Kft.) w=
rote:

> My question is slightly the same:
> how can I print a dynamically generated text file without opening a new=20
> window, or navigating from the current one?
>=20
> Thanks,
> SanTa
>=20
> ----- Original Message -----=20
> From: "Fernando Castillo Aparicio"
> To: "Dave M G" ; "PHP-General List"=20
>
> Sent: Friday, November 06, 2009 8:37 AM
> Subject: Re: [PHP] Preview button to show PDF without submitting post dat=
a?
>=20
>=20
> You could just open in a new window a php script that generates the=20
> "preview" pdf with a content-type header for pdf.
>=20
> header("Content-type: application/pdf");
>=20
> Or if the "preview" pdf is not dinamic, just point the url to the pdf.
>=20
> 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=3D"_blank", or better target=3D"pdf" if you want consecutive
> requests to open in the same window instead of a new one everytime.
>=20
> Note: if you are not using transitional html and care about validation, t=
he=20
> target attribute is not allowed. In that case you would need javascript t=
o=20
> open a new window.
>=20
>=20
>=20
>=20
> ________________________________
> De: Dave M G
> Para: PHP-General List
> Enviado: vie,6 noviembre, 2009 04:58
> Asunto: [PHP] Preview button to show PDF without submitting post data?
>=20
> PHP Users,
>=20
> 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
>=20
> When the user clicks "submit", it emails that PDF document to the
> intended recipient.
>=20
> 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 for=
m.
>=20
> I think this might need JavaScript, but I'm not sure.
>=20
> Is this possible?
>=20
> Thank you for any advice.
>=20
> --=20
> Dave M G
>=20
> --=20
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>=20
>=20
>=20
>=20

Print it where?

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-m9tL+PjkSv/XL3LOYEiy--

Re: Preview button to show PDF without submitting post data?

am 06.11.2009 12:38:21 von Ashley Sheridan

--=-0oipxcfbtuPyk7ruYj97
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Fri, 2009-11-06 at 12:21 +0100, Sándor Tamás (HostWare Kft.) w=
rote:

> On a printer, of course. Else I'd say show, or preview :)
>=20
> SanTa
>=20
> ----- Original Message -----=20
> From: "Ashley Sheridan"
> To: "Sándor Tamás (HostWare Kft.)"
> Cc: "PHP-General List"
> Sent: Friday, November 06, 2009 12:14 PM
> Subject: Re: [PHP] Preview button to show PDF without submitting post dat=
a?
>=20
>=20
> On Fri, 2009-11-06 at 12:11 +0100, Sándor Tamás (HostWare Kft.)=
wrote:
>=20
> > 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 -----=20
> > From: "Fernando Castillo Aparicio"
> > To: "Dave M G" ; "PHP-General List"
> >
> > Sent: Friday, November 06, 2009 8:37 AM
> > Subject: Re: [PHP] Preview button to show PDF without submitting post=20
> > 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=3D"_blank", or better target=3D"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,=
=20
> > the
> > target attribute is not allowed. In that case you would need javascript=
to
> > open a new window.
> >
> >
> >
> >
> > ________________________________
> > De: Dave M G
> > Para: PHP-General List
> > 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 an=
d
> > re-filling all the fields with the selected data, I'd like to be able t=
o
> > open a new window with an example PDF without actually submitting the=20
> > form.
> >
> > I think this might need JavaScript, but I'm not sure.
> >
> > Is this possible?
> >
> > Thank you for any advice.
> >
> > --=20
> > Dave M G
> >
> > --=20
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
> >
>=20
> Print it where?
>=20
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>=20
>=20
>=20


I mean what printer? One local to you (at the server) or to the user?

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-0oipxcfbtuPyk7ruYj97--

Re: Preview button to show PDF without submitting post data?

am 06.11.2009 12:46:34 von Ashley Sheridan

--=-E0SN5T2pc12IOijGAQEm
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Fri, 2009-11-06 at 12:42 +0100, Sándor Tamás (HostWare Kft.) w=
rote:

> 
>=20
> Oh, I see. To the user.
> I mean he can chose options how he wants to see datas, then on PHP I
> generate the html or csv, then make it printed on the users printer
> (of course, he can chose which printer he wants to use).
> =20
> =20
> ------------------------------------------------
>=20
> I mean what printer? One local to you (at the server) or to the user?
>=20
>=20
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>=20
>=20
>=20

Copying back the general list in again.

You can't print out a PDF to the local users printer without opening a
new window or frame, and you'll need Javascript to do that as well. What
you could do is open up the new window, run the print command on that
window with Javascript, and then user Javascript to close that window
afterwards. This relies on the user having a PDF reader plugin in their
browser. I doubt I'm alone when I say that I hate this plugin, and tend
to remove it on my computers, in which case, the PDF will attempt to be
downloaded by the browser.

There's nothing that PHP can do with this, as PHP has nothing to do with
what the user agent (browser) does with the content.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-E0SN5T2pc12IOijGAQEm--

Re: Preview button to show PDF without submitting post data?

am 06.11.2009 16:03:30 von Paul M Foster

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?

am 07.11.2009 06:59:35 von Dave M G

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?

am 07.11.2009 13:35:40 von Ashley Sheridan

--=-HrcfQWBbBR3tTPbRYW3s
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

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



--=-HrcfQWBbBR3tTPbRYW3s--

Re: Preview button to show PDF without submitting post data?

am 08.11.2009 12:48:07 von Carlos Medina

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.
>
Hallo Dave,
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 submittingpost data?)

am 08.11.2009 13:38:48 von Dave M G

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 '';
}

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 withoutsubmitting post data?)

am 08.11.2009 13:40:10 von Ashley Sheridan

--=-ozj8E1J5/vWFeKiwmKbT
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Sun, 2009-11-08 at 21:38 +0900, Dave M G wrote:

> PHP List,
>=20
> 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.
>=20
> 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.
>=20
> All good, but I don't need that second window open once the PDF has been
> shown to the user.
>=20
> For some reason I can't kill that second window. I've tried two methods.
> Killing it with PHP, and killing it with JavaScript.
>=20
> Here's the PHP version:
>=20
> if (isset($_POST['preview']))
> {
> $pdf->Output("preview.pdf", "D");
> die("PDF プレビュã=83= BCå‡=BA=
しました / PDF Preview Displayed");
> }
>=20
> Here's the JavaScript version:
>=20
> if (isset($_POST['preview']))
> {
> $pdf->Output("preview.pdf", "D");
> echo '