How to Creat PDF file in PHP while Submit the Form

First open fpdf.org and Download Zip of class file in your System.
UnZip the download files in folder and rename the folder "fpdf ".

Put this folder in the Server[in your application folder] from where it will be call.
fpdf.php file is the Key file of this total process. All class are written in this File.
so Be careful about it.

now in your PHP code ....... in the file where want to show this PDF file.
In Demo.php
if ($_REQUEST['submit'] == "submit")
{
# hear you can put what ever code you want ..........................
#
# Now for PDF creation you have to put this code.....

require('fpdf.php');
class PDF extends FPDF
{
}
//Instanciation of inherited class
$pdf=new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','',12);
$pdf->cell(40,10,'Hello I am checking ');
$pdf->Output();
?>


Now for some help to show Images in PDF and Put some
Text on above the images or any part of the PDF.

What ever Picture or Images you want to put do it first.

$pdf->Image('images/BackGround.JPG',1,150,200);
1 - is left margin.
150- upper margin.
200- size of Image.
For linux server be careful in Images Extantion.

If you want to take gap of lines....
$pdf->Ln(1); ---- This is for one line gap.

To print value which come through POST
$pdf->Write(0,$_POST['User_Name']);

Through those You can easily create PDF file through PHP
from the value of the form when we Submit.

Thank You.


Comments

Anonymous said…
Good post.

Popular posts from this blog