Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
454 views
in Technique[技术] by (71.8m points)

php - Export a web-page to a PDF with FPDF

Complicated question with a (hopefully) simple answer.

I'm looking into FPDF to export a web-page to a PDF. The web-page has been formatted for Print media, but since print media can be kind of iffy with CSS/HTML rendered object, I was hoping exporting to a PDF and then printing would make for less of a design headache.

I've scrounged through the FPDF website and I'm not seeing a function for the one thing I was hoping to see. Some kind of include() function. I see a bunch of lines about formatting content, which I'm hoping means

Am I over thinking this? Can I simply use include() after the FPDF constructor and then any content from there in will be printed with the page?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The FPDF library is not meant for directly rendering HTML markup into a PDF.

If that's what you're looking to do, you could try one of the solutions designed specifically for that purpose. For example, the html2pdf library, which among other things is based on the FPDF library. You can also consider using an external API like DocRaptor, which is a cost-effective solution based on the very costly Prince XML program.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...