Knowledge Base
MilesWeb / How-Tos

Learn to Generate PDF Files with PHP

Approx. read time : 2 min

FPDF, a PHP class, enables you to generate PDF files, and doesn’t depend on additional PHP libraries.

Available for free, it can be downloaded from its official website’s download section. Its download package comprises of all the essential files as well as some tutorials on using it.

The package can be uploaded on your MilesWeb account using FTP, or using File Manager in cPanel and extracted it after that. Then place the extracted contents in any folder on your account, which will then get converted into the FPDF installation folder.

The basic example of using FPDF is by using the below PHP code (you should select the FPDF package in the folder where the PHP file with the code is placed):

Suppose you have downloaded and extracted the FPDF package within a folder called ~/public_html/fpdf/.

Additionally, you can create a new PHP file called toPDF.php within the same folder and insert the above code. Then save the file and try accessing it through your browser:

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

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

Avatar
Pallavi is a Digital Marketing Executive at MilesWeb and has an experience of over 4 years in content development. She is interested in writing engaging content on business, technology, web hosting and other topics related to information technology.
Need help? We’re always here for you.
Register Your Free Domain Name
OFFER EXPIRES IN
04
min
59
sec