Generating PDF files with PHP
by Waqas Yousaf
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 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.
I am writing down a pretty basic code below to make use of fpdf.
<? require('fdpf/fpdf.php'); $ObjPdf = new FPDF(); $ObjPdf->AddPage(); $ObjPdf->SetTextColor(0,0,0); $ObjPdf->SetFont('Arial',' B',16); $ObjPdf->Cell(30,20,'Please generate the pdf for me..'); $ObjPdf->Output(); ?>
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.
December 6, 2017
December 5, 2017
April 4, 2017