user961627
user961627

Reputation: 12747

wkhtmltopdf unicode and custom fonts on server

I have an HTML page that is converted to PDF via wkhtmltopdf. Everything works nice and dandy on my local machine, Arabic fonts, PDF conversion to them, new custom fonts. I used @font-face, locally stored fonts, and utf-8 encoding. No problems.

But up on the server, not only do (1) Arabic characters turn into black boxes, but (2) even not-that-extraordinary English fonts (like Georgia and Impact) stop working. The PDF is rendered in plain sans-serif. That is, if it renders at all. At times it doesn't even produce output. I've added @font-face rules on my CSS for the server but wkhtmltopdf doesn't seem to pick them up. I know these fonts and paths are fine on the server because the HTML page uses the same CSS style sheet and it renders perfectly.

If I do simple plain text without any odd fonts, wkhtmltopdf works fine.

Any ideas? Does this have to do with being on the server? My local machine has Windows 7, the server's running Linux.

Upvotes: 3

Views: 3837

Answers (1)

user961627
user961627

Reputation: 12747

Problem solved. I did indeed need to upgrade my hosting plan so I could run the wkhtmltopdf static binary with X11. Although the Linux machine only has some Nimbus fonts on it, Arabic and other fonts are working fine for me by adding the font files and using @font-face css rules.

Additional note: to get Arabic text rendering properly using custom Arabic font files, I generated the required font files and css rules using FontSquirrel, with "No subsetting" under "Expert" rendering options.

Upvotes: 1

Related Questions