Wednesday, 15 February 2012

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



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

i using dompdf v.0.6.1 downloaded github convert html pdf file. facing fontdisplay issue while adding custom font in configuration. dompdf_font_family_cache.dist.php

i used http://eclecticgeek.com/dompdf/load_font.php generate unicode tamil font(latha microsoft font) .i have copied fonts respective folders.

but see fonts not printing is.

my code:

<p style="font-family: tamil-latha, verdana, sans-serif;" >தமிழ்</p>

but printed in pdf :

both values not same. there box coming near font , dot on lastly character missing..

note: have added newly created font dompdf_font_family_cache.dist.php

'tamil-latha' => array ( 'normal' => dompdf_font_dir . 'latha', 'bold' => dompdf_font_dir . 'latha', 'italic' => dompdf_font_dir . 'latha', 'bold_italic' => dompdf_font_dir . 'latha', ),

i have raised same question in github here : https://github.com/dompdf/dompdf/issues/838

suggested solution was: utilize dompdf v.0.6.2 there no such version available here : https://github.com/dompdf/dompdf help me if able v.0.6.2

dompdf appears have issues utf-8 encoding. tried sample dompdf , ran same issue did. however, tried tcpdf (also free) appears work well.

here code sample, , total source can 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'); ?>

php unicode fonts dompdf

No comments:

Post a Comment