DOMPDF does not support Cyrillic characters. Easy fix?

2.6k views Asked by At

I want to use russian letters in my html pages which i later convert into a PDF using DOMPDF. all of the russian letters are shown as question marks.

What is the easiest fix for this?

i've seen something called mbstring module. I think this will not work for me because the instalation requires a command line or something. I guess it's something that i dont have access in my vertual server (not localhost).

I see that this DOMPDF problem with Cyrillic characters has some value (second answer from top). but it's only for Times and Times New Roman. But how could I do the same thing for other fonts as well? (unless there is even easier fix)

Just remember, no command line installations. I don't thing my web hosting allows that naughtiness.

1

There are 1 answers

3
Boriss On BEST ANSWER

Alright, I fixed my issue and this is how i did it. The most convenient way is to find .ttf files of desired fonts on the internet or using Google Fonts. If you are using Google Fonts, then make sure that the desired font has normal, bold, italic and bold Italic versions.

If your using Google Fonts, then add it to your HTML using the method (Google Fonts give you this as one of the options for font installation). DOMPDF will capture and install the fonts* itself once you refresh the page. After that I leave everything else in your own hands since the font is installed now.

OR

if you found a font fille (.ttf) on the internet, make also sure that you have bold, normal, italic and italic bold versions. Use: YOUR SITE/dompdf-0.6.1/www/fonts.php (or where ever it might be located) to add a font manually.

*footnote: DOMPDF has a problem when font-weight is declared in numbers ex: font-weight:700. Google Fonts does exactly that.. so most likely you will have to get the @font-face{} from the link src, copy paste into notepad, replace all 700 with bold and all 400 with normal. and then use that on your HTML instead of the original link method.**

**more footnotes: I use Safari to visit the link src because Google Fonts adjusts their code for each browser seperatelly. Safary seems to be identical to DOMPDF. if you use ex google chrome to optain @font-face code, then your code won't work on DOMPDF cause there are no .ttf files, only .woff2 with google chrome.

HEAD ACHE! NOT VERY CONVINIENT, BUT HEY, WORKS!