"php dompdf html to pdf converter font rendering issue in v.0.6.1" Code Answer

1

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');

?>
By Rodrigo Busa on February 12 2022

Answers related to “php dompdf html to pdf converter font rendering issue in v.0.6.1”

Only authorized users can answer the Search term. Please sign in first, or register a free account.