spipu / html2pdf

OFFICIAL PROJECT | HTML to PDF converter written in PHP
http://html2pdf.fr/en/default
Open Software License 3.0
1.67k stars 745 forks source link

Handle special chars #736

Closed vespino closed 1 year ago

vespino commented 1 year ago

I’m trying to add the following name to a PDF: Fēnix, it is however displayed as F?nix probably due to incorrect encoding. My input is UTF8. What should I convert it to?

Edit: I just did a test with mPDF with almost the same HTML and this shows Fēnix as Fēnix.

vespino commented 1 year ago

The following shows Fenix in the PDF:

$html2pdf=new Html2Pdf('P', 'A4', 'nl');
$html2pdf->writeHTML('Fēnix');
$html2pdf->output();

When getting the name from my database, it's shown as F?nix.

vespino commented 1 year ago

The solution is to apply a UTF-8 font to all elements.

* { font-family:freeserif; }