vespino
vespino

Reputation: 1940

html2pdf not showing character correctly, encoding for ē

I'm struggling with some characters in a PDF I'm trying to create with html2pdf. The following code creates the PDF, but ē is shown an e.

$html2pdf=new Html2Pdf();
$html2pdf->writeHTML('<h1>Fēnix</h1>');
$html2pdf->output();

When getting the name from my database, ē is shown a ?.

$query=$mysqli->query('SELECT name FROM table WHERE id=1;');
$result=$query->fetch_assoc();

$html2pdf=new Html2Pdf();
$html2pdf->writeHTML('<h1>'.$result['name'].'</h1>');
$html2pdf->output();

This is the way I connect to my database:

$mysqli=new mysqli('host', 'user', 'pass', 'db');

I have also tried adding a charset:

$mysqli->set_charset('utf8');

Or initiating the class with parameters:

$html2pdf=new Html2Pdf('P', 'A4', 'nl');
$html2pdf=new Html2Pdf('P', 'A4', 'nl', true, 'UTF8');

Other characters that are giving issues are: Ś ą ł ś

Both server and database are UTF-8.

Upvotes: 0

Views: 449

Answers (1)

vespino
vespino

Reputation: 1940

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

* { font-family:freeserif; }

Upvotes: 1

Related Questions