使用wkhtmltopdf从HTML生成Google Web字体和PDF [英] Google Web Fonts and PDF generation from HTML with wkhtmltopdf
问题描述
我使用 wkhtmltopdf 转换PDF格式的HTML文件;它给出令人惊讶的良好的结果,完全像WebKit做的PDF。
我使用 Google Web Fonts ,让用户可以自定义他们编辑的文档的外观,为他们提供在几种字体之间进行选择的可能性。
问题是,我无法使用Google字体将这些HTML文件转换为PDF格式wkhtmltopdf。我看到其他人有同样的问题。< :在CSS中直接声明@ font-face也不起作用。 p>
要通过 wkhtmltopdf
将HTML转换为PDF,请尽量避免 woff
字体。使用与
base64 的
Google Web Fonts
的 truetype
编码。
最近我尝试使用Google Web Fonts的Google网络字体。在浏览器中显示正确,但在将HTML转换为PDF后不显示。
在广泛搜索网络后,我发现工具可以将字体编码为 base64
格式,并获得 @ font-face
的CSS
阅读解决方案这里。
I am using wkhtmltopdf to convert HTML files in PDF format; it gives surprisingly good results, rendering the PDF exactly as WebKit would do.
I am using Google Web Fonts to give users the possibility to customize the appearence of the document they edited, offering them the possibility to choose between a few fonts. It also works perfectly in a browser.
Problem is, I don't get the Google Fonts working when converting such HTML files to PDF with wkhtmltopdf. I read other people had the same issue.
Could anyone please help me fixing this?
EDIT: declaring @font-face directly in the CSS does not work either.
To convert HTML to PDF by wkhtmltopdf
try to avoid woff
font face. Use the truetype
format of the Google Web Fonts
with base64
encode.
Recently I tried to use a Google web font from Google Web Fonts. In the browser it shows correctly but it doesn't show after converting HTML to PDF.
After searching the web extensively, at last, I found tools to encode fonts to the base64
format and also got CSS for @font-face
.
Read the solution here.
这篇关于使用wkhtmltopdf从HTML生成Google Web字体和PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!