Skip to content

Instantly share code, notes, and snippets.

@settermjd settermjd/gist:6778757
Last active Dec 24, 2015

Embed
What would you like to do?
Handle Umlauts and other characters in DOMPDF
$pdf = new DOMPDF();
$pdf->load_html(utf8_decode($customtext));
@settermjd

This comment has been minimized.

Copy link
Owner Author

commented Oct 1, 2013

I was having trouble outputting them and found this to work. I uncovered it at http://www.dashinteractive.net/dompdf/index.php?v=1609697 (right at the end). Please be aware that this was tested with PDFLib as the PDF backend.

@bsweeney

This comment has been minimized.

Copy link

commented Oct 2, 2013

utf8_decode() isn't nice to your text unless your characters are already iso-8859-1 compatible. It's a lossy (and dumb) decode, meaning if PHP can't find a suitable replacement it will discard your characters (or replace with ? ... I don't remember which). Review the comments in the documentation.

If you're using dompdf v0.6.x you can encode your document with UTF-8, just be sure to supply the content type meta tag indicating the encoding (see the Unicode How-To). If you're using v0.5.x you should encode your document in iso-8859-1 to begin with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.