从html页面生成PDF [英] PDF generation from html pages
问题描述
要从html页面生成pdf文件,我使用了MPDF,FPDF,DOMPDF等库.
To generate pdf file from html page I have used libraries like MPDF , FPDF, DOMPDF etc.
在每个pdf库中,我发现以下问题.
In each pdf library I found following issues.
- mpdf导致不必要的分页符
- FPDF需要更多的文字.等等
当我使用DOMPDF时,它可以很好地工作,但是大表并没有扩展到下一页,并且pdf在没有生成下一页的情况下破裂了.
When I used DOMPDF it worked fine but large table didn't expanded to next page and pdf broke without generating next pages.
然后我搜索了另一个pdf库,就知道了关于 TCPDF 的信息.
Then I searched for another pdf library and I came to know about TCPDF.
所以我想知道"TCPDF"的缺点是什么?
SO I want to know what are the disadvantages of "TCPDF"?
推荐答案
wkhtmltopdf 是PDF生成的一个很好的选择.它具有平滑的集成,效果令人赞叹.不过,您将不得不将二进制文件安装到服务器中.如果您使用的是VPS或专用服务器,这将不是问题.
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.
有一个使用它的PHP库,您可以在这里找到它: https://github.com/KnpLabs/活泼
There's a PHP lib for using it, you can find it here: https://github.com/KnpLabs/snappy
此外,对于您遇到的大表问题,还有一个不错的解决方案.也许它也可以帮助您使用另一个库,请在此处查看: https: //code.google.com/p/wkhtmltopdf/issues/detail?id=566
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
这篇关于从html页面生成PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!