Search code examples
laravelpdftcpdf

Custom Font installation in Laravel TCPDF


I am trying to add custom unicode font(http://www.freebanglafont.com/catetory.php?b=173) with Laravel TCPDF. But it throwing error like "TCPDF ERROR: Could not include font definition file:"

My controller code:

$pdf->setFontSubsetting(true);
$fontname = TCPDF_FONTS::addTTFfont(public_path().'/fonts/SolaimanLipi.ttf', 'TrueTypeUnicode', '', 32);
$pdf->SetFont($fontname, '', 14, '', true);
$pdf->AddPage();

I have put my font in "public/fonts" and followed the documentation http://www.tcpdf.org/fonts.php


Solution

  • Try placing your font in the tcpdf/fonts folder or setting the K_PATH_FONTS constant to the location of your font. Either way, it is unnecessary (and probably unwise) to keep your font folder in the public folder.