In this post we are going to discuss how we can generate Portable Document Files using PHP. Creating PDFs dynamically is very importent especially when we have dynamic data. Actually this is very easy since we can find pre-developed library.
You should download fpdf.php file first.
Then you can create PDF.php file as follows.
Now you're ready to generate PDF files. Refer this code.
Then you can create PDF.php file as follows.
require('fpdf.php'); class PDF extends FPDF { function Header() { //write your own code segment } function Footer() { //write your own code segment }
Now you're ready to generate PDF files. Refer this code.
require('pdf.php'); $pdf=new PDF("P","mm","A4"); $pdf->SetMargins(25.4,25.4,25.4); $pdf->AddPage(); $pdf->Cell(30, 5, 'This is the Fist page'); $pdf->AddPage(); $pdf->SetY(25.4); $pdf->SetFont('Arial', 'BIU', 12); $pdf->Cell(0, 5, 'Sample Text', 0, 1); ob_start(); $pdf->Output();//pdf will be downloaded ob_end_flush();
No comments:
Post a Comment