samedi 16 avril 2016

How to add fonts in HTML2PDF?

I am using HTML2PDF in Laravel 5.1 and I need to add two fonts. I've tried searching for answers but they don't work for me whenever I try them.

I have tried the following (based on searches):

  • Go to http://ift.tt/1QegtHh to generate .php and .zip files of my fonts
  • I found a thread that said to put the files in html2pdf\_tcpdf_5.0.002\fonts\ because it's the default directory for fonts in FPDF. I went to vendor\spipu\html2pdf to look for such directory but found nothing. So I just placed the generated files in public\fonts as well as the .ttf files.
  • I also added the following to my code: $cambria_path = base_path() . '\public\fonts\cambria.php'; $html2pdf->addFont('cambria', '', $cambria_path);

    However, this does not work. This is the error that shows up: TCPDF ERROR: Could not include font definition file: cambria

  • I also tried this one: $cambria_path = base_path() . '\public\fonts\cambria.ttf'; $cambria = $html2pdf->pdf->addTTFfont($cambria_path, 'TrueTypeUnicode', '', 32);

    but it says Call to undefined method HTML2PDF_myPdf::addTTFfont().

What am I doing wrong and how do I add at least one font (it would be better if I can add at least two though)? Thank you in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire