9951 explained code solutions for 126 technologies


php-tcpdfHow do I install php-tcpdf on CentOS 7?


  1. Install EPEL repository:
sudo yum install epel-release
  1. Install PHP-TCPDF package:
sudo yum install php-tcpdf
  1. Verify the installation by checking the version of the installed package:
php -m | grep tcpdf

The output should be something like:

tcpdf
  1. To use the TCPDF library in your PHP code, include the following line:
require_once('/usr/share/php/tcpdf/tcpdf.php');
  1. To create a PDF file, create a new instance of the TCPDF class:
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  1. To generate the PDF file, call the Output method:
$pdf->Output('example.pdf', 'I');
  1. To learn more about the TCPDF library, please refer to the official documentation.

Edit this code on GitHub