From a year there is question in stackover flow, developer having a trouble to add custom or paid font in dompdf laravel,
The fonts showing in HTML view but not included in PDF.
I have face the same issue and added this to help others.
**DomPDF provide a method to setOption**
here is an code example.
$pdf = PDF::loadView('promo-template.pdf', compact('data'))
->setOption('fontDir', public_path('/fonts'));
In this code i have use setOption function with two agruments . (Option, value),
I have set option as a font Directory, and value would be the path of you want to set for fonts.
It will setup compile your font pdf html UTF-8 and genrate a json file for font to be included in PDF.
Top comments (0)