9951 explained code solutions for 126 technologies


php-tcpdfHow do I use fonts in PHP TCPDF?


To use fonts in PHP TCPDF, you can do the following:

  1. Download the desired font file from the TCPDF font repository
  2. Extract the font file from the compressed file
  3. Add the font file to the tcpdf/fonts directory
  4. Add the following code to the tcpdf_config.php file
<?php
$fontname = TCPDF_FONTS::addTTFfont('/path/to/font/file', 'TrueTypeUnicode', '', 96);
  1. Use the font in the PDF document
<?php
$pdf->SetFont($fontname, '', 14, '', false);
  1. Generate the PDF document
<?php
$pdf->Output('example.pdf', 'I');
  1. The PDF document will be generated with the specified font.

Edit this code on GitHub