从html页面生成PDF[英] PDF generation from html pages

本文是小编为大家收集整理的关于从html页面生成PDF的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

从HTML页面生成PDF文件,我使用了MPDF,FPDF,DOMPDF等库.

.

在每个PDF库中,我发现以下问题.

  • MPDF导致不必要的页面中断
  • FPDF需要更多的写入.等

当我使用DOMPDF时,它工作正常,但是大表并未扩展到下一页,而PDF则在没有生成下一页的情况下破裂.

然后我搜索了另一个PDF库,然后知道 tcpdf .

所以我想知道" tcpdf"的缺点是什么?

推荐答案

PDF生成的一个很好的替代方法是 wkhtmltopdf .它具有平稳的集成,结果很棒.但是,您必须将二进制文件安装到服务器中.如果您在vps或专用的情况下,这将不是问题.

有一个可以使用它的php lib,您可以在这里找到它: https://github.com/knplabs/活泼

另外,还有一个很好的解决方案,可以解决您遇到的大桌问题.也许它也可以帮助您使用另一个lib,在这里看看: https:https:https:https:https:https://code.google.com/p/wkhtmltopdf/issues/detail?id=566

本文地址:https://www.itbaoku.cn/post/2090909.html

问题描述

To generate pdf file from html page I have used libraries like MPDF , FPDF, DOMPDF etc.

In each pdf library I found following issues.

  • mpdf causes unnecessary page breaks
  • FPDF needs more writting. etc

When I used DOMPDF it worked fine but large table didn't expanded to next page and pdf broke without generating next pages.

Then I searched for another pdf library and I came to know about TCPDF.

SO I want to know what are the disadvantages of "TCPDF"?

推荐答案

A great alternative for PDF generation is wkhtmltopdf. It has a smooth integration and the result is awesome. You will have to install the binary into your server, though. If you're on a VPS or dedicated, this will not be a problem.

There's a PHP lib for using it, you can find it here: https://github.com/KnpLabs/snappy

Also, there's a nice solution for the large table problem you have. Maybe it can help you with another lib too, take a look here: https://code.google.com/p/wkhtmltopdf/issues/detail?id=566