gpt4 book ai didi

html - TCPDF 通过 CSS font-family 设置字体

转载 作者:行者123 更新时间:2023-11-28 01:11:00 25 4
gpt4 key购买 nike

我使用的是最新版本的TCPDF,发现在使用writeHtml 方法时无法使用CSSfont-family 设置字体。设置字体的唯一方法是使用 SetFont,但这对我来说效果不佳,因为文档需要多种字体并且模板是使用一个 HTML View 文件创建。

到目前为止,这是模板文件:

<style media="all">
html, body, p, h1, h2, h3, td, span {
font-family: 'HeavyDisplay' !important;
font-size: 10pt;
}
</style>

<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td style="font-size:27pt;color:#2998ff">Tax Receipt</td>
<td rowspan="2">Company Name</td>
</tr>
<tr>
<td style="font-size:7pt;letter-spacing:.8pt;color:#999">&nbsp;<br>Please retain for income tax purposes</td>
</tr>
</table>

我可以确认 font-size 属性有效。

此外,我已经尝试为每个标签内联 font-family 属性,但这并没有什么不同。

这是 TCPDF 的错误吗?

最佳答案

请不要使用库 TCPDF 或其他使用 <style> 的库标签或 css文件

<style media="all">
html, body, p, h1, h2, h3, td, span {
font-family: 'HeavyDisplay' !important;
font-size: 10pt;
}
</style>

最好改用样式属性 <style>标签或 css文件

<body style="font-family: 'HeavyDisplay' !important;font-size: 10pt;"></body>

关于html - TCPDF 通过 CSS font-family 设置字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37762149/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com