如何用PHP生成PDF文件? [重复]

时间:2023-01-24 11:28:35

I have some HTML that includes bolding, italics, small tag, big tag, blockquote tag, bullets, and numbered items. I need to convert it to PDF via PHP. I tried FPDF, but it was entirely too complex. I tried the html2pdf PHP library, which uses FPDF, but it was very buggy and unreliable. What do you recommend?

我有一些HTML,包括粗体,斜体,小标签,大标签,blockquote标签,项目符号和编号项目。我需要通过PHP将其转换为PDF。我尝试过FPDF,但它太复杂了。我尝试了使用FPDF的html2pdf PHP库,但它非常错误且不可靠。您有什么推荐的吗?

Note: Imagine your typical resume. I'm needing to format something like that.

注意:想象一下你的典型简历。我需要格式化这样的东西。

4 个解决方案

#1


1  

Take a look at FPDF

看看FPDF

#2


0  

I've had a lot of success with dompdf.

我在dompdf上取得了很大的成功。

Make sure you have valid HTML though, or it can get into a loop. It's very simple to use - about 4 lines to convert an HTML file to a PDF.

确保您拥有有效的HTML,或者它可以进入循环。它使用起来非常简单 - 大约4行将HTML文件转换为PDF。

#3


0  

I have had good experiences with PrinceXML. Their rendering engine is very good. Passes acid2 and has good .svg support so you can include vector images instead of bitmaps to keep the .PDF relatively small (which is important when generating reports which need to be sent as an attachment).

我对PrinceXML有很好的经验。他们的渲染引擎非常好。传递acid2并具有良好的.svg支持,因此您可以包含矢量图像而不是位图,以使.PDF保持相对较小(这在生成需要作为附件发送的报告时很重要)。

(note that princexml is proprietary software).

(请注意,princexml是专有软件)。

#4


0  

http://www.ros.co.nz/pdf/

I once used the above to turn incredibly complex architect's tile specifications into PDFs on a dynamic basis and it worked out well. I found the class very approachable and easily modifiable.

我曾经使用上面的内容将令人难以置信的复杂建筑师的瓷砖规格转化为动态的PDF格式并且效果很好。我发现课程非常平易近人,而且很容易修改。

#1


1  

Take a look at FPDF

看看FPDF

#2


0  

I've had a lot of success with dompdf.

我在dompdf上取得了很大的成功。

Make sure you have valid HTML though, or it can get into a loop. It's very simple to use - about 4 lines to convert an HTML file to a PDF.

确保您拥有有效的HTML,或者它可以进入循环。它使用起来非常简单 - 大约4行将HTML文件转换为PDF。

#3


0  

I have had good experiences with PrinceXML. Their rendering engine is very good. Passes acid2 and has good .svg support so you can include vector images instead of bitmaps to keep the .PDF relatively small (which is important when generating reports which need to be sent as an attachment).

我对PrinceXML有很好的经验。他们的渲染引擎非常好。传递acid2并具有良好的.svg支持,因此您可以包含矢量图像而不是位图,以使.PDF保持相对较小(这在生成需要作为附件发送的报告时很重要)。

(note that princexml is proprietary software).

(请注意,princexml是专有软件)。

#4


0  

http://www.ros.co.nz/pdf/

I once used the above to turn incredibly complex architect's tile specifications into PDFs on a dynamic basis and it worked out well. I found the class very approachable and easily modifiable.

我曾经使用上面的内容将令人难以置信的复杂建筑师的瓷砖规格转化为动态的PDF格式并且效果很好。我发现课程非常平易近人,而且很容易修改。