PHP DOMPDF html to PDF converter font rendering issue in v.0.6.1

本小妞迷上赌 提交于 2019-12-04 19:01:17

Dompdf appears to have issues with UTF-8 encoding. I tried your sample with dompdf and I ran into the same issue you did. However, I also tried it with tcpdf (also free) it appears to work well.

Here is the code for your sample, and the full source can be downloaded here.

<?php

header('Content-type: text/html; charset=UTF-8') ;//chrome
require_once('tcpdf.php');

// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

$pdf->setFontSubsetting(true);

$pdf->SetFont('freeserif', '', 12);

$pdf->AddPage();

$utf8text = '
<html><head>  
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body>
<p>தமிழ்</p>
</body></html>';

$pdf->writeHTML($utf8text, true, 0, true, true);

$pdf->Output('example_008.pdf', 'I');

?>

I tried with tcpdf as suggested by josh. Now the previous word is coming fine but new word is not displayed properly.

$utf8text = '
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>     <body><p>தமிழ்      முந்திரி </p></body>        </html>';

Actual Answer in PDF is :

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!