I'm having a problem with TCPDF. My custom font (and any other included font) isn't working when using writeHTML.
$tcpdf = tcpdf_get_instance();
$fontname = $tcpdf->addTTFfont('/antiquariat/sites/default/files/fonts/tstar-regular-webfont.ttf', 'TrueTypeUnicode', '', 32);
$tcpdf->SetFont('tstarwebfont', '', 16);
$tcpdf->writeHTML($html);
Fonts won't change, even if I use "helvetica" or any other font. Second thing is, that the custom font isn't generated at all, but in first place I struggle with that not even any other font is used.
This is how i did it using TCPDF:
$pdf->AddFont('yourfont1'); //custom font
$pdf->AddFont('yourfont2'); //custom font
Now, to use it inside a writeHTML:
$html = '
<style>
h1 {
font-family: yourfont1;
font-size: 40pt;
text-align:center;
}
</style>
<h1>Testing FONT</h1>
';
$pdf->writeHTML($html, true, false, true, false, '');
As no one answered to me and I didn't get it up like desired, I switched to DOMPDF which is working fine so far! This is not quite the solution I was looking for, but a working one!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With