Reputation: 9007
I'm using the latest version of TCPDF, and found that I cannot set fonts with CSSfont-family
when using the writeHtml
method. The only way that the font is set is if I use SetFont
, but that won't work out nicely for me as the document needs to have multiple fonts and the template is created using one HTML view file.
Here's that template file so far:
<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"> <br>Please retain for income tax purposes</td>
</tr>
</table>
I can confirm that the font-size
property works.
Additionally, I have tried inlining the font-family
property for each tag, but that doesn't make a difference.
Is this a bug with TCPDF?
Upvotes: 4
Views: 3878
Reputation: 95
Please don't use library TCPDF or others using <style>
tag or css
file
<style media="all">
html, body, p, h1, h2, h3, td, span {
font-family: 'HeavyDisplay' !important;
font-size: 10pt;
}
</style>
better you use style attribute instead <style>
tag or css
file
<body style="font-family: 'HeavyDisplay' !important;font-size: 10pt;"></body>
Upvotes: 1