php 带有 HTML 标签的 FPDF 文本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15272050/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
FPDF Text with HTML tags
提问by Rob
I'm using FPDF to create an A4 sized PDF, I can add text/images and this is working fine. I have a dynamically generated string which contains some HTML tags (BR etc) and was wondering how I can have that output onto the PDF as opposed to literally printing the tags out.
我正在使用 FPDF 创建一个 A4 大小的 PDF,我可以添加文本/图像,这工作正常。我有一个动态生成的字符串,其中包含一些 HTML 标签(BR 等),并且想知道如何将该输出输出到 PDF 上,而不是逐字打印标签。
$centre = urldecode($row_CertDetails['centre_name']);
$pdf->Text(10, 110, $centre);
I've seen on some forums people mentioning WriteHTML, however my version of FPDF doesn't seem to include that.
我在一些论坛上看到有人提到WriteHTML,但是我的 FPDF 版本似乎不包括那个。
Is it an add-on?
它是一个附加组件吗?
回答by hakre
Yes, it is an Add-On:
是的,它是一个附加组件:
Write HTML
Author: Clément Lavoillotte
License: FPDFThis is an enhancement of the
WriteHTML()method from tutorial 6. Supported tags are: ...
编写 HTML
作者:Clément Lavoillotte
执照:FPDF这是
WriteHTML()教程 6 中方法的增强。支持的标签是:...
Please see Write HTML FPDF Script #42which I think is the latest version, but feel free to browse the FPDF scripts/Add-Ons.
请参阅我认为是最新版本的Write HTML FPDF Script #42,但请随意浏览 FPDF 脚本/附加组件。
回答by Rob
I've solved it anyway.
反正我已经解决了。
Because I'm also using FPDI, what I did was extract the contents of the class in http://www.fpdf.org/en/script/script42.phpand put it inside the FPDI.phpfile.
因为我也在使用 FPDI,所以我所做的是在http://www.fpdf.org/en/script/script42.php 中提取类的内容并将其放入FPDI.php文件中。

