How to generate PDF files with PHP?

FPDF is a PHP class which allows you to generate PDF files, and does not depend on additional PHP libraries.

FPDF is free and can be downloaded from the official website’s download section. The download package contains all necessary files, along with some tutorials on how to use it.

You can upload the package on your SiteGround account via FTP, or using File Manager in cPanel and extract it after that. You can place the extracted contents in any folder on your account, which will then turn into the FPDF installation folder.

A basic example of using FPDF is with the following PHP code (you must extract the FPDF package in the folder where the PHP file with the code is located):

Let's say that you have downloaded and extracted the FPDF package inside a folder called ~/public_html/fpdf/. You can create a new PHP file called toPDF.php inside the same folder and insert the above code. You can then save the file and try to access it through your browser:

http://yourdomain.com/fpdf/toPDF.php

Upon execution, the PHP script will generate a PDF file in your browser.