php-tcpdfHow do I install TCPDF using Yum on a PHP server?
- Install the EPEL repository on the server by running the command:
yum install epel-release
- Install the TCPDF package using the command:
yum install php-tcpdf
- Enable the TCPDF extension in the php.ini configuration file by adding the following line:
extension=tcpdf.so
- Restart the PHP service on the server with the command:
systemctl restart php-fpm
- Verify that the TCPDF extension is installed and enabled by running the command:
php -m | grep tcpdf
Output: tcpdf
- To use TCPDF, include the library with the following code:
require_once('/usr/share/php/tcpdf/tcpdf.php');
- Create a new instance of the TCPDF class and use it to generate PDFs:
$pdf = new TCPDF();
$pdf->AddPage();
$pdf->Write(0, 'Hello world!');
$pdf->Output('example.pdf', 'D');
Code explanation
**
yum install epel-release
- This command installs the EPEL repository on the server.yum install php-tcpdf
- This command installs the TCPDF package.extension=tcpdf.so
- This line enables the TCPDF extension in the php.ini configuration file.systemctl restart php-fpm
- This command restarts the PHP service on the server.php -m | grep tcpdf
- This command verifies that the TCPDF extension is installed and enabled.require_once('/usr/share/php/tcpdf/tcpdf.php');
- This code includes the TCPDF library.$pdf = new TCPDF();
- This creates a new instance of the TCPDF class.
## Helpful links
More of Php Tcpdf
- How do I use the PHP TCPDF WriteHTMLCell function?
- How do I add a watermark to PDFs using PHP and TCPDF?
- How do I use the setfont function in PHP TCPDF?
- How can I generate a QR code using PHP and TCPDF?
- How do I install TCPDF with Composer in a PHP project?
- How can I use TCPDF's writeHTML() function in PHP?
- How do I use the setxy function in PHP TCPDF?
- How do I set the page orientation when using PHP TCPDF?
- How do I set the margins using PHP TCPDF?
See more codes...