PHP 中最快的 PDF 生成速度?

发布于 2024-10-03 07:44:12 字数 164 浏览 1 评论 0原文

我正在尝试动态生成一些报告,非常简单的带边框的 HTML 表格。

我尝试过 TCPDF,它最多可以渲染 400 行,但超过这个数量(大约 20 页)它就无法处理。 DOMPDF 甚至无法做到这一点。

这些报告可能有数千行。

关于更快的库或更好的攻击计划有什么想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

溺ぐ爱和你が 2024-10-10 07:44:12

尝试 php-wkhtml2x PHP 扩展。它使用流行的网络引擎webkit(Chrome和Safari使用它)

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

别闹i 2024-10-10 07:44:12

我使用 FPDF 库,输出速度快且资源高效。尝试一下...
http://www.fpdf.org/

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

若有似无的小暗淡 2024-10-10 07:44:12

我不知道这些方法是否是最快的,但它们肯定可以处理 20 多个页面。

您可以将 Latex 与 php 结合使用:
http://www.linuxjournal.com/article/7870

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

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/

奈何桥上唱咆哮 2024-10-10 07:44:12

根据报告,PHP 可能不是正确的解决方案,您可能会考虑使用另一种替代语言(例如 perl)来完成此任务。我没有使用其他服务器端语言的经验,但需要记住这一点。一定要遵循@Pekka 的建议并确定限制并努力调整这些限制。

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.

听不够的曲调 2024-10-10 07:44:12

事实
php.ini 可以处理数千行。

我的假设

很可能您将从数据库中获取数据并保存到数组中,然后您将循环写入行。

这会吃内存。

我的建议

尝试在从数据库获取时写入pdf。删除存储到数组的步骤。

检查 php ini 中分配的执行时间和内存。

最后当你生成它时,想想PDF是否可以处理它:-)
肯定会有巨大的尺寸。

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 .

甜`诱少女 2024-10-10 07:44:12

尝试 DocRaptor.com。这是一个基于网络的应用程序,可以将 html 转换为 pdf。便于使用。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文