Wkhtmltopdf not displaying TrueType fonts

心不动则不痛 提交于 2019-12-10 09:55:50

问题


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.


回答1:


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.




回答2:


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;
 }



回答3:


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


来源:https://stackoverflow.com/questions/14467820/wkhtmltopdf-not-displaying-truetype-fonts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!