0

From last 6 hours trying best to show progress bar wile pdf is generated in TCPDF but not successful.

I am using TCPDF API for HTML to PDF generation, But the problem is that while generating the PDF we can't use custom javascript, Can we show progress bar while PDF is generated?

Any idea please?

Suleman Ahmad
  • 2,025
  • 4
  • 28
  • 43

2 Answers2

1

I am not sure why you say "can't use custom javascript". If you just want a "loading icon" yoy should do this - show loading icon (from js) - ajax request to php file that generates the pdf into a server file - on success you get a link to a generated pdf. (for this solution you might try some estimation based on how large would be the generated file)

If you want an accurate progressive, you should add some estimation on php file. Let's say when you generate the pdf you know how many pages you will generate and each "addPage" command you save the status of completeness in a file or a memcached key. On you JavaScript side you call a file each second that reads that status of completeness.

catalinux
  • 1,462
  • 14
  • 26
0

No.

Even if you were able to use custom javascript, it would not be possible to get an accurate prediction of the time it will take to generate the document and therefore diplay progress - but it would be possible to get an estimate (based on extensive benchmarking). But in order to display the progress bar you'd need custom javascript and to change the processing to decouple the threads on the browser and server. This is discussed more in this question (which IMHO is not a duplicate of the post referenced).

Community
  • 1
  • 1
symcbean
  • 47,736
  • 6
  • 59
  • 94