Generating PDF files with PHP

Generating PDF files with PHP

No site is completed with out pdf reports today and generating PDF reports with PHP is super easy. There are so many open source free libraries to tackle this job but I like FPDF class the best for its simplicity, size and ease of use.

Just head to the to download a free copy of the library. Unzip it in your web directory and include “fpdf.php” and that’s about it.

I am writing down a pretty basic code below to make use of fpdf.

$ObjPdf = new FPDF();
$ObjPdf->SetFont('Arial',' B',16);
$ObjPdf->Cell(30,20,'Please generate the pdf for me..');

Lets say you have save the code in your local webserver’s root directory with file name “pdf.php” and you have library in a folder named “fpdf”, then you’ll open pdf.php in your browser, it will generate a pdf file.

Happy experimenting.



I am a web developer based in Lahore. I spend my days playing with wordpress, code igniter, wide variety of key web projects and frameworks.

Leave a Reply

Your email address will not be published. Required fields are marked *

12 + eighteen =

Translate »