DomPDF, special characters

Created on 9 February 2017, almost 8 years ago
Updated 26 June 2024, 6 months ago

I am using DomPDF, and some of the special characters are printed as a question-mark ("?").

An example was the checkmark ( βœ“ ).

After some research, an article on stackoverflow showed the answer:
http://stackoverflow.com/questions/5136067/dompdf-special-characters

The main problem is the default font.

At the moment, the default CSS file in entity-print only sets a single font:
font-family: sans-serif;

Instead, it needs to have something like this; this below worked for me, but other font-families are of course possible:

font-family: Verdana, Tahoma, "DejaVu Sans", sans-serif;

Then the characters showed up in the PDF.

It probably would be good to have something like this in the default CSS, or at least a comment in there that depending on the font/font-family that is used, you may not see some special-characters. However, since many people probably just try the default CSS, it should contain a working solution.

(Other note, I also changed the meta-tag in the template to this, but that seemed less of a problem)

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  ...
</head>
) 
πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • I tried so many ways to kill this problem.
    I use wkhtmltopdf to product pdf with chinese characters(中文字符)

    at last


    ...

    This add to entity-print--webform-submission--notes.html.twig all is ok.

    BUT IT'S IMPORTANT: if you use wkhtmltopdf,you must download font SimSun and set as first font like this
    body {
    font-family: "SimSun","Microsoft YaHei", Helvetica, Arial, sans-serif;
    }

Production build 0.71.5 2024