问题描述
我一直在尝试在创建pdf时使用Helvetica字体,但字体没有反映在pdf。
我做了一些google,发现一些解决方案,但没有
我在这里找到了类似的东西:
试过最后提到的解决方案
尝试的解决方案2我也尝试使用google字体api,但结果仍然不可行。
这里是一个示例
尝试的解决方案3
我尝试使用css属性@page。
但是这也不行。
一个可行的解决方案是什么。
修复 wkhtmltopdf
的字体问题最简单的方法是使用Base64编码字体()并将其包含在您的CSS中:
@ font-face {
font-family:'Helvetica';
src:url(data:font / truetype; charset = utf-8; base64,AAEAAAATAQA ...
}
这适用于所有字体(包括Google字体),并确保跨不同机器和操作系统的跨平台兼容性。
I have been trying to use Helvetica font while creating the pdf but the font is not reflected back in pdf.
I did some google and found some solutions but none are workable.
Tried Solution 1
I found similar thing here :Font issue
Tried the last solution mentioned over there
But the solution is not working.
Tried Solution 2I also tried to use google font api, but result is still not workable.helvetica font
here is an exampleExample of custom font
Tried Solution 3I tried doing it using css property @page.But that also is not working.
What is the approach for a workable solution.
The easiest way to fix wkhtmltopdf
's font problems is to Base64 encode the font (you can use this tool) and include it in your CSS:
@font-face {
font-family: 'Helvetica';
src: url(data:font/truetype;charset=utf-8;base64,AAEAAAATAQA...
}
This works with all fonts (including Google Fonts), and guarantees cross-platform compatibility across different machines and operating systems.
这篇关于helvetica字体不工作在wkhtmltopdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!