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>
)
Comment | File | Size | Author |
---|---|---|---|
#4 | 2851057-4.patch | 268 bytes | benjy |
Comments
Comment #2
benjy CreditAttribution: benjy at PreviousNext commentedWhich font does it end up using to render the tick? Is it possible to reproduce this on the /debug url? If so, we could add a test.
Comment #3
hoporr CreditAttribution: hoporr commentedThis is what I ended up using in the CSS, and the checkmarks showed up. Not sure which of these four the PDF generator actually uses, but apparently "sans-serif" by itself in the default style sheet can be ruled out :)
Comment #4
benjy CreditAttribution: benjy at PreviousNext commentedIt seems to be DejaVu Sans packaged with Dompdf that has the good unicode support. Updated the fonts in the attached patch.
Comment #5
benjy CreditAttribution: benjy at PreviousNext commentedCommitted and pushed.
Comment #8
sajidmanzoor CreditAttribution: sajidmanzoor as a volunteer and commentedHello
I am having the same issue with Chinese language.
I have tried the attached patch, added meta to page and added fonts to CSS but Chinese content is still not printing.
Please suggest a solution. I am using
Drupal 8.2.x
Comment #9
kaipipek CreditAttribution: kaipipek commentedI have problems printing Japanese (partly Chinese) characters as well. They are printed as either rectangles or question marks.