Fastest PDF generation in PHP?

↘锁芯ラ 提交于 2019-12-01 01:44:31

问题


I'm attempting to generate some reports dynamically, very simple HTML tables with borders.

I've tried TCPDF and it renders up to 400 rows just fine but anything more than that (about 20 pages) it can't handle it. DOMPDF can't even do that.

These reports can be thousands of rows.

Any idea on a faster library or a better plan of attack?


回答1:


Try php-wkhtml2x php extension. It uses popular web engine webkit(Chrome and Safari uses that)




回答2:


I use the FPDF library, the output is fast and resource-efficient. Try it out... http://www.fpdf.org/




回答3:


I don't know if these methods are the fastest, but they can certainly handle more than 20 pages.

You could use latex in combination with php: http://www.linuxjournal.com/article/7870

or Zend_Service_LiveDocx_MailMerge http://www.phphatesme.com/blog/webentwicklung/pdf-erzeugung-mit-dem-zend-framework/




回答4:


Try DocRaptor.com. It's a web-based app that converts html to pdf. Easy to use.




回答5:


It's possible that depending on the report that PHP is not the right solution you and might consider another alternative language such as perl to accomplish this. I have no experience with other server-side languages but it is something to keep in mind. Definitely follow @Pekka's advice and determine the limits and work on adjusting those.




回答6:


Fact Thousands of rows can be handled by the php.

My assumption

Most probably you will be fetching data from db and saving to an array and then you will be looping to write the rows.

This will eat memory.

My suggestion

Try to write into the pdf at time of fetching from db. remove the step of storing into an array.

check execution time and memory allocated in php ini.

At last when you generate it , think PDF can handle it or not :-) surely It will have huge size .



来源:https://stackoverflow.com/questions/4188366/fastest-pdf-generation-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!