ahk
ahk

Reputation: 61

Wkhtmltopdf not displaying TrueType fonts

We're using wkhtmltopdf to render a PDF from an HTML page however fonts such as Verdana and Georgia aren't being displayed properly. We installed the TrueType fonts on our server using these instructions. Fonts are being set inline using style tags: style="font-family: verdana, geneva;"

Any suggestions on what we can try next to get these fonts to display would be appreciated.

Upvotes: 6

Views: 11763

Answers (4)

Hani Tetouha
Hani Tetouha

Reputation: 1

For me the issue was the permissions on the installed fonts which was installed in /usr/local/share/fonts I had to set the permission for the fonts directory to chmod 755

Upvotes: 0

Jurrian
Jurrian

Reputation: 670

I am not sure if this works for this problem but I solved my problems by installing true type fonts. After that wkhtmltopdf was able to display these fonts.

Ubuntu (18.04)

apt install fonts-droid-fallback ttf-dejavu fonts-freefont-ttf fonts-liberation ttf-ubuntu-font-family

Alpine Linux (3.9)

apk add ttf-dejavu ttf-droid ttf-freefont ttf-liberation ttf-ubuntu-font-family

Upvotes: 1

Yardboy
Yardboy

Reputation: 2805

Try Arman H.'s solution posted over on this question: Google Web Fonts and PDF generation from HTML with wkhtmltopdf

Base64 encoding the fonts into your css has worked like a charm for us.

Upvotes: 4

Rachel Gallen
Rachel Gallen

Reputation: 28553

have you set up the fonts in your css correctly?

e.g.

@font-face {
 font-family: 'Verdana';
 src: url('verdana-webfont.eot');
 src: url('verdana-webfont.eot?#iefix') format('embedded-opentype'),
 url('verdana-webfont.woff') format('woff'),
 url('verdana-webfont.ttf') format('truetype'),
 url('verdana-webfont.svg#Verdana') format('svg');
 font-weight: normal;
 font-style: normal;
 }

Upvotes: 0

Related Questions