我正在使用 tFPDF 生成 PDF。 php文件是UTF-8编码的。
例如,我希望 ©
作为版权符号输出到 pdf 中。
我试过iconv
、html_entity_decode
、htmlspecialchars_decode
。当我尝试解码字符串并将其硬编码到另一个文件中并解码时,它按预期工作。所以出于某种原因,它没有以 PDF 格式输出。我试过输出缓冲。我正在使用 DejaVuSansCondensed.ttf
(真实字体)。
tFPDF 链接:http://fpdf.org/en/script/script92.php
我没有想法。我尝试了双重解码,我到处检查以确保它没有在其他任何地方被编码。
最佳答案
你需要这个:
iconv('UTF-8', 'windows-1252', html_entity_decode($str));
html_entity_decode 解码 html 实体。但由于任何原因,您必须使用 iconv 将其转换为 utf8。我想这是一个 fpdf-secret... 因为在正常的浏览器 View 中它显示正确。
关于php - FPDF 中的 html_entity_decode(使用 tFPDF 扩展),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10516960/