helvetica字体不工作在wkhtmltopdf [英] helvetica font not working in wkhtmltopdf

查看:321
本文介绍了helvetica字体不工作在wkhtmltopdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试在创建pdf时使用Helvetica字体,但字体没有反映在pdf。



我做了一些google,发现一些解决方案,但没有





我在这里找到了类似的东西:
字体问题



试过最后提到的解决方案


解决方法是 define @ font-face ,并在src链接
到可由wkhtmltopdf访问的外部主机


尝试的解决方案2
我也尝试使用google字体api,但结果仍然不可行。
helvetica字体



这里是一个示例
自定义字体示例



尝试的解决方案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

workaround is to define @font-face in your css and have src link to external host that is accessible by wkhtmltopdf

But the solution is not working.

Tried Solution 2 I also tried to use google font api, but result is still not workable. helvetica font

here is an example Example of custom font

Tried Solution 3 I 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆