dompdf character encoding UTF-8

You should read over the Unicode How-to again. The main problem is that you don’t specify a font that supports your characters. It looks like you’ve read the how-to, because you’re using the font example from that document. However the example was not meant to apply globally to any document, dompdf doesn’t include firefly (a Chinese character font) or Verdana by default.

If you do not specify a font then dompdf falls back to one of the core fonts (Helvetica, Times Roman, Courier) which only support Windows ANSI encoding. So always be sure to style your text with a font that supports Unicode encoding and has the characters you need to display.

With dompdf 0.6.0 you can use the included Deja Vu fonts. So the following should work (just the HTML):

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
  body { font-family: DejaVu Sans, sans-serif; }
</style>
<title>č s š Š</title>
</head>
<body>
  <p>??????X Ponuka číslo € černý Češký <br></p>
</body>
</html>

Leave a Comment