1

I am generating a PDF on the fly, this take upto several seconds, what I would like to do is get the browser to start the download before the pdf is generated so the user isn't sitting around wondering if it is working.

Idea I had is to flush the headers then generate and output the pdf, however I can't flush without something to flush.
So would a space at the beginning affect/invalidate the pdf file. ie " %PDF-1.4" instead of "%PDF-1.4"

Its PHP5.2 using the Zend pdf generator.

Update

As far as I can tell it does not affect the readability of the pdf, but it also doesn't make any difference to IE.

So the best solution would be to do a download site style holding page which just meta-refeshes or js-redirected to the actual pdf generation script.

Or perhaps This nice little hack

Community
  • 1
  • 1
Sam
  • 5,416
  • 7
  • 47
  • 49

1 Answers1

1

There is no meaningful way for downloading empty data and then the real file, which would be to start downloading early.

I would suggest to display some animation that the PDF file is being prepared and that the download will start in no time. This way, the user knows that something is happening (while the animation keeps him from thinking that the browser froze/crashed) and you can transfer the file the usual way.

Betaminos
  • 482
  • 4
  • 13