Generate PDF with PHP | PHP2PDF Tutorial
Why Generate PDF Files With PHP?
No site is completed with out generating PDF file reports today. There are plenty of open source free libraries to achieve this task but my personal favorite is FPDF class. I find it suitable for the task because of its simplicity, relatively smaller size and ease of use.
Just head to the fpdf.org to download a free copy of the library. Unzip it in your web directory and include “fpdf.php” and that’s about it.
Below, You can find a pretty basic no bells and whistles code to make use of fpdf library and generate pdf file with php.[php] <? require(‘fdpf/fpdf.php’); $ObjPdf = new FPDF(); $ObjPdf->AddPage();
$ObjPdf->Cell(30,20,’Please generate the pdf for me..’);
Lets say you have saved 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.