gpt4 book ai didi

php - 带有特殊字符的 TCPDF HTML 显示空 PDF 文件

转载 作者:行者123 更新时间:2023-12-02 23:24:10 33 4
gpt4 key购买 nike

我正在使用 TCPDF 库版本:5.9.011。我正在尝试将 HTML 布局执行为 PDF。为此,我尝试使用示例提供 site

$html = '<h1>HTML Example</h1>
<h2>List</h2>
Some special characters: &lt; € &euro; &#8364; &amp; è &egrave; &copy; &gt; \\slash \\\\double-slash \\\\\\triple-slash
';
// output the HTML content
$pdf->writeHTML($html, true, false, true, false, '');

//Close and output PDF document
$pdf->Output('example_006.pdf', 'I');

显然发现生成的PDF只有默认的页眉和页脚,中间内容为空白。

但是,如果我删除特殊字符,例如:

$html = '<h1>HTML Example</h1>
<h2>List</h2>
Some special characters:
';

PDF 获取 $html 中指定的中间内容

最佳答案

行前$pdf->writeHTML

$html = utf8_decode($html);

也许

$html = utf8_encode($html);

关于php - 带有特殊字符的 TCPDF HTML 显示空 PDF 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4141865/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com