Generate PDF with PHP.

Generate PDF with PHP.


Posted in : PHP Posted on : January 14, 2011 at 12:22 PM Comments : [ 0 ]

This section contains the detail about the Generating PDF with PHP.

Generate PDF with PHP

In this tutorial you will learn how to generate PDF with  PHP  in a PHP web application. FPDF is a PHP class that allows you to generate PDF files without using the PDFlib library. FPDF is free and can be downloaded from the official website's  download section or click here . The download package contains all necessary files that used generate the PDF.

             In this tutorial use 'pdffile.php'  file  and 'fpdf16'  folder for  PDFlib library. The code of  'pdffile.php' given below :

<?php
require('fpdf16/fpdf.php');

$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Times','I',16);
$pdf->Cell(0,10,'Hello World!');

$pdf->Output();
?>

In the 'pdffile.php' file :

  • First we have included the fpdf library in our file.
  • Then we have created a new instance of FPDF class.
  • Next we add a blank page in pdf document.
  • Next we have set the page font.
  • Finally we have created a cell with parameters width, height and content.
  • Then We will output it to the browser.
Output :



Download Source Code
Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics