Page 1 of 1

Redirect on task completion

Posted: Fri Dec 20, 2013 11:08 am
by ChrisRChamberlain
Hi all

PHP newbie so please be gentle :D

Apologies for posting a link rather than code, but you will see there is a lot of it.

http://www.fpdf.org/en/script/script36.php

Would like to redirect once the .pdf is displayed in the browser as the purpose of the script is to print the .pdf not necessarily view it.

Have tried the obvious but the redirect kicks in without executing the script.

TIA

Re: Redirect on task completion

Posted: Fri Dec 20, 2013 12:47 pm
by requinix
To print the PDF the user must be able to see the PDF. There is no way around that.

Re: Redirect on task completion

Posted: Sat Dec 21, 2013 1:01 am
by ChrisRChamberlain
requinix

Thanks for your reply - I appreciate the .pdf has to display in order to be printed.

I was hoping that it would be possible for the printer to be called and the .pdf to be displayed momentarily before the redirect kicks in.

Is there no way of stopping the execution of the script at that point?

Re: Redirect on task completion

Posted: Sat Dec 21, 2013 7:12 pm
by requinix
It might be possible but I wouldn't suspect so. When the PDF opens it will show the print dialog; if you are able to redirect in the first place (using embedded Javascript in the PDF) then the user might lose the ability to print (since the document isn't there anymore).

Re: Redirect on task completion

Posted: Mon Dec 23, 2013 6:28 am
by ChrisRChamberlain
requinix

Ignoring the javascript that brings up the printer dialog, the script does allow the option of outputting the .pdf to a string.

So if the string were to be printed, would the .pdf have to display in the browser?

Re: Redirect on task completion

Posted: Mon Dec 30, 2013 1:51 pm
by requinix
"Printing" in PHP means outputting to the browser, not printing like to a user's printer. Getting the PDF as a string just means that you don't have to use a file (on the server) to hold the contents, which affords you a bit more flexibility in terms of what you do with it. However that doesn't impact the ability to have it printed for the user.

Re: Redirect on task completion

Posted: Thu Jan 02, 2014 2:13 am
by ChrisRChamberlain
requinix

Thanks for the further explanation. :)