Reputation: 1280
I am generating PDF using mPDF PHP library. I am able to successfully generate it using the default font configuration. However, I want to render a Google font in my PDF. I tried using the steps mentioned in this link, but it did not work. Below is the code I use.
$mPDFO = new mPDF('utf-8', 'A4', 0, '', 10, 10, 10, 0, 0, 0, 'L');
Can anyone help me using Google Font in mPDF ?
Upvotes: 3
Views: 6311
Reputation: 2064
As mentioned in mPDF's documentation, it's not possible to use remote fonts directly by referencing them in the HTML. Follow the below steps to use custom fonts:
Download the fonts & upload them to mPDF's fonts directory /ttfonts
Declare the font-family you need to use in config_fonts.php
under: $this->fontdata
Now comes the main part. You need to mention the font-family in the instance that you create to call mPDF's object which is what you missed, like so:
$mPDFO = new mPDF('utf-8', 'A4', 0, 'Source Sans Pro', 10, 10, 10, 0, 0, 0, 'L');
Finally call the SetFont
method like $mPDFO->SetFont('Source Sans Pro');
just below your instance
Upvotes: 10