I'm using this pkg with Laravel... so i want to add custom font.
my code:
$pdf = new \setasign\Fpdi\Fpdi();
$pdf->AddPage();
$pdf->AddFont('SuisseIntl-Regular', '', public_path('fonts/suisseIntl-segular.php'));
$pdf->setSourceFile('PdfDocument.pdf');
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, 10, 10, 100);
$pdf->SetFont('SuisseIntl-Regular');
$pdf->SetTextColor(255, 0, 0);
$pdf->SetXY(30, 30);
$pdf->Write(0, 'This is just a simple text');
$pdf->Output('I', 'generated.pdf');
I went to this website and download two files suisseIntl-regular.php
and SuisseIntl-Regular.z
, I put them in public/fonts/...
dir
I got this error:
FPDF error: Incorrect font definition file name: /Users/a/Documents/Sites/w-c-backend/public/fonts/suisseIntl-segular.php
even the suisseIntl-regular.php is there:(
The 3rd parameter of AddFont()
accepts only a file name (not a full path). To specify the directory where the font is located, use the 4th parameter:
$pdf->AddFont('SuisseIntl-Regular', '', 'suisseIntl-segular.php', public_path('fonts'));