invoice Creation in FPDF Tamil


Invoice Creation

I Hope you learn more about FPDF in this tutorials. This time i will trying to create a simple invoice pdf format using FPDF

Source Code

<?php
     require_once "fpdf/fpdf.php"; //fpdf supporting file
 
     $pdf = new FPDF('P','mm','A4');
    /* A4 - 210 * 297 mm */
	$pdf -> AddPage();
 
    //addFont(family,style,file)
    $pdf -> addFont('Roboto','','Roboto.php'); 
    $pdf -> SetFont('Roboto','',12);
 
    //Creating Fill and Border color (RGB color value)
    $pdf -> SetDrawColor(223, 88, 42); 
    $pdf -> SetFillColor(223, 88, 42); 
 
    //Draw rectangle box (x,y,w,h,style)
    $pdf -> Rect(10,10,190,10,'DF');
 
    //Creating Fill and Border color (RGB color value)
    $pdf -> SetDrawColor(243, 243, 243); 
    $pdf -> SetFillColor(243, 243, 243); 
 
    //Draw rectangle box (x,y,w,h,style)
    $pdf -> Rect(10,20,190,50,'DF');
    //Image(string file ,float x ,float y , float w, float h , string type)
    $pdf -> Image("img/inv_logo.png",20,30,20,20,'PNG');
 
    // Cell(width,hei$ght,text,border,line Break, align,colorFill)
 
    $pdf -> Cell(33,15,'',0,1);
    $pdf -> Cell(33,7,'',0,0);
    $pdf -> Cell(120,7,'Tutor Joes Computer Education',0,1);
 
    $pdf -> SetFont('Roboto','',10);
    $pdf -> Cell(33,7,'',0,0);
    $pdf -> Cell(120,7,'Cherry Road,Vincent Bus Stop',0,1);
    $pdf -> Cell(33,10,'',0,0);
    $pdf -> Cell(100,10,'Phone : 9043017689',0,0);
    $pdf -> SetFont('Roboto','',12);
    $pdf -> Cell(50,10,'INVOICE',0,1);
 
    $pdf -> SetFont('Roboto','',10);
    $pdf -> Cell(133,7,'',0,0);
    $pdf -> Cell(50,7,'DATE',0,1);
 
    $pdf -> Cell(133,7,'',0,0);
    $pdf -> Cell(50,7,'INVOICE NO',0,1);
 
    $pdf -> Ln(15);// Line Break
    $pdf -> Cell(185,7,'<Payment terms (due on receipt, due in X days)>',0,1,'R');
 
    $pdf -> SetDrawColor(162, 162, 162); 
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(85,10,'BILL TO','B',0);
    $pdf -> Cell(10,7,'',0,0);
    $pdf -> Cell(85,10,'SHIP TO','B',1);
 
    $pdf -> Ln(3);// Line Break
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(85,7,'MR. Ram Kumar',0,0);
    $pdf -> Cell(10,7,'',0,0);
    $pdf -> Cell(85,7,'MR. Ram Kumar',0,1);
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(85,7,'XXX Software Solutions',0,0);
    $pdf -> Cell(10,7,'',0,0);
    $pdf -> Cell(85,7,'XXX Software Solutions',0,1);
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(85,7,'Test Address Line',0,0);
    $pdf -> Cell(10,7,'',0,0);
    $pdf -> Cell(85,7,'Test Address Line',0,1);
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(85,7,'9632015478',0,0);
    $pdf -> Cell(10,7,'',0,0);
    $pdf -> Cell(85,7,'9632015478',0,1);
 
    $pdf -> Ln(3);// Line Break
 
    $pdf -> SetDrawColor(223, 88, 42); 
    $pdf -> SetFillColor(223, 88, 42); 
 
    //Draw rectangle box (x,y,w,h,style)
    $pdf -> Rect(15,130,180,8,'DF');
 
    $pdf -> SetTextColor(255, 255, 255);
    $pdf -> SetFillColor(223, 88, 42);  
 
    $pdf -> Ln(1.5);// Line Break
 
    $pdf -> SetFont('Arial','B',10);
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(95,7,'DESCRIPTION',0,0,'C',true);
    $pdf -> Cell(28.3,7,'QTY',0,0);
    $pdf -> Cell(28.3,7,'UNIT PRICE',0,0);
    $pdf -> Cell(28.3,7,'TOTAL',0,1);
 
 
 
    $pdf -> SetFillColor(225, 225, 225);
    $pdf -> SetTextColor(98,98,98);
    $pdf -> SetDrawColor(162, 162, 162);
 
    $pdf -> Ln(1);// Line Break
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(95,7,'','L',0);
    $pdf -> Cell(28.3,7,'',0,0);
    $pdf -> Cell(28.3,7,'',0,0);
    $pdf -> Cell(28.3,7,'0.00','R',1,'R');
 
    $pdf -> SetFillColor(243, 243, 243);
    $pdf -> SetTextColor(98,98,98);
    $pdf -> SetDrawColor(162, 162, 162);
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(95,7,'','L',0,'',true);
    $pdf -> Cell(28.3,7,'',0,0,'',true);
    $pdf -> Cell(28.3,7,'',0,0,'',true);
    $pdf -> Cell(28.3,7,'0.00','R',1,'R',true);
 
    $pdf -> SetFillColor(225, 225, 225);
    $pdf -> SetTextColor(98,98,98);
    $pdf -> SetDrawColor(162, 162, 162);
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(95,7,'','L',0);
    $pdf -> Cell(28.3,7,'',0,0);
    $pdf -> Cell(28.3,7,'',0,0);
    $pdf -> Cell(28.3,7,'0.00','R',1,'R');
 
    $pdf -> SetFillColor(243, 243, 243);
    $pdf -> SetTextColor(98,98,98);
    $pdf -> SetDrawColor(162, 162, 162);
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(95,7,'','L',0,'',true);
    $pdf -> Cell(28.3,7,'',0,0,'',true);
    $pdf -> Cell(28.3,7,'',0,0,'',true);
    $pdf -> Cell(28.3,7,'0.00','R',1,'R',true);
 
    $pdf -> SetFillColor(225, 225, 225);
    $pdf -> SetTextColor(98,98,98);
    $pdf -> SetDrawColor(162, 162, 162);
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(95,7,'','L',0);
    $pdf -> Cell(28.3,7,'',0,0);
    $pdf -> Cell(28.3,7,'',0,0);
    $pdf -> Cell(28.3,7,'0.00','R',1,'R');
 
    $pdf -> SetFillColor(243, 243, 243);
    $pdf -> SetTextColor(98,98,98);
    $pdf -> SetDrawColor(162, 162, 162);
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(95,7,'','L',0,'',true);
    $pdf -> Cell(28.3,7,'',0,0,'',true);
    $pdf -> Cell(28.3,7,'',0,0,'',true);
    $pdf -> Cell(28.3,7,'0.00','R',1,'R',true);
 
    $pdf -> SetFillColor(225, 225, 225);
    $pdf -> SetTextColor(98,98,98);
    $pdf -> SetDrawColor(162, 162, 162);
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(95,7,'','L',0);
    $pdf -> Cell(28.3,7,'',0,0);
    $pdf -> Cell(28.3,7,'',0,0);
    $pdf -> Cell(28.3,7,'0.00','R',1,'R');
 
    $pdf -> SetFillColor(243, 243, 243);
    $pdf -> SetDrawColor(162, 162, 162);
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(95,7,'','L',0,'',true);
    $pdf -> Cell(28.3,7,'',0,0,'',true);
    $pdf -> Cell(28.3,7,'',0,0,'',true);
    $pdf -> Cell(28.3,7,'0.00','R',1,'R',true);
 
    $pdf -> SetFillColor(225, 225, 225);
    $pdf -> SetDrawColor(162, 162, 162);
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(95,7,'','L',0);
    $pdf -> Cell(28.3,7,'',0,0,true);
    $pdf -> Cell(28.3,7,'',0,0);
    $pdf -> Cell(28.3,7,'0.00','R',1,'R');
 
    $pdf -> SetFillColor(243, 243, 243);
    $pdf -> SetDrawColor(162, 162, 162);
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(95,7,'','L',0,'',true);
    $pdf -> Cell(28.3,7,'',0,0,'',true);
    $pdf -> Cell(28.3,7,'',0,0,'',true);
    $pdf -> Cell(28.3,7,'0.00','R',1,'R',true);
 
    $pdf -> SetFillColor(225, 225, 225);
    $pdf -> SetDrawColor(162, 162, 162);
 
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(95,7,'','LB',0);
    $pdf -> Cell(28.3,7,'','B',0);
    $pdf -> Cell(28.3,7,'','B',0);
    $pdf -> Cell(28.3,7,'0.00','RB',1,'R');
 
    $pdf -> SetDrawColor(162, 162, 162);
    //Creating Center Line
 
    $pdf -> Line(100,138,100,215);
    $pdf -> Line(128.5,138,128.5,215);
    $pdf -> Line(165,138,165,215);
 
    $pdf -> Ln(3);// Line Break
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(95,7,'Remarks / Payment Instructions',0,0,'L');
    $pdf -> Cell(55,7,'SUBTOTAL',0,0,'R');
    $pdf -> Cell(29,7,'0.00','B',1,'R');
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(95,7,'',0,0,'L');
    $pdf -> Cell(55,7,'DISCOUNT',0,0,'R');
    $pdf -> Cell(29,7,'0.00','B',1,'R');
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(95,7,'',0,0,'L');
    $pdf -> Cell(55,7,'SUBTOTAL LESS DISCOUNT',0,0,'R');
    $pdf -> Cell(29,7,'0.00','B',1,'R');
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(95,7,'',0,0,'L');
    $pdf -> Cell(55,7,'TAX RATE',0,0,'R');
    $pdf -> Cell(29,7,'0.00%','B',1,'R');
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(95,7,'',0,0,'L');
    $pdf -> Cell(55,7,'TOTAL TAX',0,0,'R');
    $pdf -> Cell(29,7,'0.00%','B',1,'R');
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(95,7,'',0,0,'L');
    $pdf -> Cell(55,7,'SHIPPING HANDLING','B',0,'R');
    $pdf -> Cell(29,7,'0.00%','B',1,'R');
 
    $pdf -> Cell(5,7,'',0,0);
    $pdf -> Cell(95,7,'',0,0,'L');
    $pdf -> Cell(55,7,'Balance Due',0,0,'R');
    $pdf -> Cell(29,7,'-','B',1,'R');
 
    $pdf -> SetDrawColor(223, 88, 42); 
    $pdf -> SetFillColor(223, 88, 42); 
 
    //Draw rectangle box (x,y,w,h,style)
    $pdf -> Rect(10,280,190,10,'DF');
 
 
    $pdf -> Output(); // Display output
?>
View Demo