css - 从 html 创建 pdf 时字体加倍
问题描述
我正在使用 node.js 构建一个 Web 应用程序,它应该从给定的 HTML 片段创建一个 pdf。
为此,我正在使用 html-pdf 包。除了一种粗体字体外,一切正常。当使用这个字体粗细为 900 的字体时,看起来字体加倍了偏移量。您可以在图片中看到效果(尤其是在“3”处)。
我的 CSS 代码如下所示:
@font-face {
font-family: 'Proxima Nova Condensed';
src: url("/fonts/ProximaNovaCond-Regular.ttf") format("truetype");
font-weight: 400;
}
@font-face {
font-family: 'Proxima Nova Condensed';
src: url("/fonts/ProximaNovaCond-Bold.ttf") format("truetype");
font-weight: 700;
}
@font-face {
font-family: 'Proxima Nova Condensed';
src: url("/fonts/ProximaNovaCond-Extrabold.ttf") format("truetype");
font-weight: 800;
}
@font-face {
font-family: 'Proxima Nova Condensed';
src: url("/fonts/ProximaNovaCond-Black.ttf") format("truetype");
font-weight: 900;
}
在 Web 应用程序中这有效,但是在生成 pdf 时我遇到了这个问题。
谁能帮我这个?
解决方案
你可以尝试添加font-style
吗?
推荐阅读
- docker - LogStash Docker 只是在启动后停止
- python - 在 Django 中使用 Jinja2 加载 css 文件
- typescript - 在 TypeScript 中,如何在具有多个类型参数的方法中推断出泛型类型参数?
- regex - 用于查找不是结束字符的最后一个事件的正则表达式
- javascript - React.js,在所有 getDownloadURL 函数完成后打印一些东西
- spring - Spring数据Cassandra可以与动态模型和键空间一起使用吗
- visual-studio-code - VS Code设置中的变量,如何?
- python - `print(help('modules'))` 中是否缺少任何标准库模块
- bash - Perl Pack 在 Shell 变量上解包
- bash - 根据bash / posh中数组中的列匹配值将CSV拆分为两个文件