0

I am using FPDF to create a pdf document in an iFrame... During the pdf creation the script communicates and gets a lot of data from the server, and then I would like to display a progress bar.. That is why I have put the php generator in an iFrame.. then my plan was that the php script could send the looped data to the parent window..

e.g. every time a loop is made it says $count++;, then I know how many loops it has gone through, and I already know that it is going to limit the rows to the first 200 rows.. Then I would like to display the looped data in the parent widow like so: $count of §goal has been generated successfully!.. At the moment I am using jQuery, where I ask the php to echo some jQuery script every time a loop is made to display the results like so window.parent.count($count, $goal);.. Count in the parent winodw and it actually works well until the PDF has to be shown.. then I get an error message that tells me that the script is unable to display the PDF because the page already has outputted data..

Does anybody know how to make the PHP to send the data to the parent window, so I prevet the using of echo?

Sorry for my bad english.. if wished I can try to upload my script later for you to see...

2
  • 1
    PHP cannot send to client anything. PHP knows nothing of iframes, parent windows and even of windows in general. it can only respond to a request made from client. Commented Jan 20, 2013 at 12:03
  • is there another way to execute javascript through php, than echo the script, then? Commented Jan 20, 2013 at 12:22

1 Answer 1

1

I do it a bit differently...

I also wrote an application in which the PDF generator needs to fetch a rather large amount of data, so the generation takes a few seconds.

I use jQuery to fetch a php-page in the background. During this download, the screen turns gray and displays a classic "please wait"-circle. The only output that the php-file generates is an "OK" echo, together with a file link, when the generation has been completed. Instead of displaying the file inline, I save the PDF in a folder ($pdf->Output('filename.pdf','S')) and offer it as a download using the provided link and the jQuery-callback.

I hope you understand what I mean. Maybe this thought will help you a bit further.

EDIT: Don't know if this will work, but I just thought of it... You could save the file and output the filename. Using jQuery, you could then refresh the contents of the iframe to fetch a page in which you display the already saved PDF inline...

Sign up to request clarification or add additional context in comments.

3 Comments

I like the idea.. :) But the thing is that this is used to create a list of labels size 60 mm x 44 mm. The script gets prices and stock information from the server and generates a list of labels in a pdf document that can be printed directly from the web.. So if I had to save the document and then download it afterwords it won't be as intuitive as I would like it to be.. :) But thanks for the input..
It was the only way I could think of to display some sort of wait-for-it dialog, because - like Your Common Sense already said above - PHP cannot send a client anything. I'm updating my answer to include some new thoughts.
Ohh yeah.. I could save the PDF file locally and then set jQuery to send a command back to the parent widow to change the iframe source to the PDF file.. that may work.. :) great idea

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.