dompdf 字符编码 UTF-8
2022-08-30 16:47:06
我试图用正确的字符创建pdf,但有“?”字符。我创建了一个测试php文件,我试图提供最佳解决方案。如果我在浏览器中打开html,我看起来还行
UTF-8 --> UTF-8 : X Ponuka číslo € černý Češký
但是当我查看pdf时,我看到了这个
UTF-8 --> UTF-8 : X Ponuka ?íslo € ?erný ?ešký
这是我的所有代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>č s š Š</title>
</head>
<body>
<?php
require_once("dompdf/dompdf_config.inc.php");
$tab = array("UTF-8", "ASCII", "Windows-1250", "ISO-8859-2", "ISO-8859-1", "ISO-8859-6", "CP1256");
$chain = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <style></style><title>č s š Š</title></head><body>';
foreach ($tab as $i)
{
foreach ($tab as $j)
{
$chain .= "<br> $i --> $j : ".iconv($i, $j, 'X Ponuka číslo € černý Češký <br>');
}
}
$chain .= '<p style="font-family: firefly, verdana, sans-serif;">??????X Ponuka číslo € černý Češký <br></p></body></html>';
echo $chain;
echo 'X Ponuka číslo € černý Češký <br>';
$filename = 'pdf/_1.pdf';
$dompdf = new DOMPDF();
$dompdf->load_html($chain, 'UTF-8');
$dompdf->set_paper('a4', 'portrait'); // change these if you need to
$dompdf->render();
file_put_contents($filename, $dompdf->output());
?>
</body>
</html>
我做错了什么?我尝试了很多很多选择,我发现:(有什么想法吗?