PDF generation through a very slow PHP HTML

Asked

Viewed 227 times

0

I am developing a system in PHP that has a module for the PDF export of a certain information that Gero in HTML, but this process is very slow because I think it is a lot of information (on average 40 pages);

The lib I’m using is the dompdf.

Code I use for export:

$dompdf = new DOMPDF();
$dompdf->loadHtml($meuhtml);
$dompdf->setPaper("A4", "portrait");
$dompdf->render();
$dompdf->stream("meupdf.pdf", array("Attachment" => TRUE));

I have read the documentation of dompdf and I have seen that the community speaks a lot about the slowness of the library but I do not see many alternatives.

I know the library Snappy also, but how she uses the wkhtmltopdf I ended up not being able to use, because the system is in a shared hosting.

How can I improve performance for PDF export?

  • Does this html content always change? what could be done is to save the PDF already rendered on the server and when the user makes the request he accesses this already saved file

  • @Thiagocosta HTML is not fixed and it is done through a query to the database, that is, the information is dynamic as the user uses the system to generate the reports.

  • @zuguhu has already gone through this problem and using the same dompdf library. In my case I decided to switch and generation the pdf from dompdf to a puglin in Javascript. in the middle case was a hand in the wheel for performance. Gives a search by "pdf via javascript", may be an option.

  • @Marcusitalo So I came to research and the libraries I found, most need the Node to work and as I use shared hosting, I can’t use them, can say a library that serves me without needing the Node itself?

  • @zuguhu has puglins in jQuery, or you can make your own library. One option is via popup and print example. No need to use Node, just script . js . Sorry I don’t remember which library you specify.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.