php中的PDF导出

2022-01-12 00:00:00 pdf formatting export converter php

有没有可能在不更改任何ini修改的情况下以更短的执行时间在pdf中写入大量数据..?

Is there any possibility to write huge data in pdf without changing any ini modifications with less executing time..?

目前我正在使用 tcpdf 插件.

Currently I'm using tcpdf plugin.

推荐答案

如果您打算从 PHP 创建 PDF,pdflib 会帮助您.

If your intention is to create a PDF from PHP, pdflib will help you.

否则,如果你想通过 PHP 将 HTML 页面转换为 PDF,你会发现这里有点麻烦.

Otherwise, if you want to convert an HTML page to PDF via PHP, you'll find a little trouble outta here.

所以,我知道的选项是:

So, the options I know are:

DOMPDF :包装 HTML 并构建 PDF 的 PHP 类.效果很好,可定制(如果你知道 PHP),基于 pdflib,如果我没记错的话,它甚至需要一些 CSS.坏消息:当 HTML 很大或非常复杂时速度很慢.

DOMPDF : PHP class that wraps the HTML and builds the PDF. Works good, customizable (if you know PHP), based on pdflib, and, if I remember correctly, it takes even some CSS. Bad news: slow when the HTML is big or very complex.

HTML2PS:与 DOMPDF 相同,但此文件首先转换为 .ps(GhostScript),然后,以您需要的任何格式(PDF、JPEG、PNG).对我来说,它比 DOMPDF 好一点,但有同样的速度问题.哦,与 CSS 更好的兼容性.

HTML2PS: same as DOMPDF, but this one converts first in .ps (GhostScript), then, in whatever format you need (PDF, JPEG, PNG). For me it is a little better then DOMPDF, but have the same speed problem. Oh, better compatibility with CSS.

这两个是PHP类,但是如果你可以在服务器上安装一些软件,并通过passthru()system()访问它,看看这些也是:

Those two are PHP classes, but if you can install some software on the server, and access it through passthru() or system(), give a look to these too:

wkhtmltopdf:基于WebKit(Safari的包装器),真的快速而强大.似乎它是即时将 HTML 转换为 PDF 的最佳方法(目前),使用 CSS2 的 3 页 XHTML 文档仅需 2 秒.反正这是一个最近的项目,所以 google.code 页面经常更新.

wkhtmltopdf: based on WebKit (Safari's wrapper), it's really fast and powerful. Seems like it is the best one (at the moment) for HTML to PDF conversion on the fly, taking only 2 seconds for a 3 page XHTML document with CSS2. It's a recent project anyway, so the google.code page is often updated.

htmldoc : 这个是坦克,真的从来没有停止/崩溃.截至 2007 年,该项目似乎已死,但如果您不需要 CSS 兼容性,这对您来说可能会很好.

htmldoc : this one is a tank, it really never stops/crashes. The project seems dead, as of 2007, but if you don't need CSS compatibility this can be nice for you.

tcpdf - 这是 fpdf 的增强和维护版本.它具有 tpdf 的所有主要功能,并且执行速度更快,输出也很好.有关使用两个最流行的 PDF 生成类的详细教程:TCPDF 和 FPDF,请关注 此链接.我认为你应该继续使用 TCPDF.

tcpdf - this is an enhanced and maintained version of fpdf. It has all the main Features of tpdf and it also has faster execution time with great output. For detailed tutorial on using the two most popular PDF generation classes: TCPDF and FPDF, please follow this link. I think you should continue using TCPDF.

还可以查看这些帖子:

  1. 用 PHP 将 HTML + CSS 转换为 PDF?李>
  2. 哪一个是 PHP 的最佳 PDF-API?
  3. 在 PHP 中将 html 导出为 PDF?
  4. 将带有 PHP 变量的 HTML 写入 PDF 文件?
  5. 如何用php将html转成pdf?
  6. 将html导出为pdf的工具
  7. 将 PHP 文件中的 HTML 转换为 PDF 文件

相关文章