Search code examples
phppdffontspdf-generationfpdf

How to add fonts using tFPDF



I try to create pdf file using tFPDF with custom font.
I put arial font inside font/unifont folder.
I use this code to create pdf file:

$pdf->AddFont('arialbd','','arialbd.ttf',true);

$pdf->SetFont('arialbd','',16);
$pdf->Cell(40,6, 'OÜ Kersti Võlu Koolituskeskus', 0, 1);

$pdf->SetFont('arialbd','',10);
$pdf->Cell(40,12,'REGISTREERIMISLEHT', 0, 1);

$pdf->Output('test.pdf', 'I');

It works well on localhost, but when I uploaded this file on server, it shows me an error:

Warning: fopen(C:\xampp\htdocs\koolitus\wp-content\plugins\koolitus\fpdf/font/unifont/arialbd.ttf)

I see that library tries to load a font from my localhost, but I don't even set a path, just use font name
How to add fonts properly?


Solution

  • Delete all *.php and *.dat files in font/unifont folder except ttfonts.php. All this files will be re-created (with right path).