使用FPDF将网页导出为PDF [英] Export a web-page to a PDF with FPDF

查看:471
本文介绍了使用FPDF将网页导出为PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

带有(希望)简单答案的复杂问题.

Complicated question with a (hopefully) simple answer.

我正在研究FPDF,以将网页导出为PDF.该网页已针对打印媒体进行了格式设置,但是由于打印媒体对CSS/HTML呈现的对象可能有点陌生,所以我希望导出为PDF,然后进行打印,这将减轻设计的麻烦.

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.

我已经浏览了FPDF网站,但没有看到我希望看到的功能.某种include()函数.我看到了一堆关于格式化内容的行,我希望这是

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

我是否在考虑这个问题?我可以在FPDF构造函数之后简单地使用include(),然后将其中的任何内容打印到页面上吗?

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?

推荐答案

FPDF库不能直接将HTML标记呈现为PDF.

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

如果您要这样做,则可以尝试专门为此目的设计的一种解决方案.例如, html2pdf库,该库尤其基于FPDF库.您还可以考虑使用 DocRaptor 之类的外部API,这是基于非常昂贵的 Prince XML 程序.

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.

这篇关于使用FPDF将网页导出为PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆