Port80 Forums Ilisys Web Hosting Fast Hit Web Hosting

Our Platinum Sponsors:


Go Back   Port80 Forums > Development & Code > php & mySQL

Reply
 
Thread Tools Display Modes
  #11  
Old 30-06-2009, 08:35 AM
stevebramley's Avatar
stevebramley stevebramley is offline
Senior Member
AWIA Member
 
Join Date: Jun 2006
Location: Applecross, Perth
Age: 42
Posts: 177
stevebramley is on a distinguished road
Default pdf generation stuff

Vee,
Code:
 
//grab the free pdf app:  http://www.fpdf.org/
 
require('/includes/fpdf153/fpdf.php');
 
//extend it with your page settings etc
//---------- begin pdf ----------------
     class PDF extends FPDF{
 
      var $unique_id = "";
      var $company_name = "";
      var $abn = "";
      var $address1 = "";
      var $address2 = "";
      var $country = "";
      var $email = "";
      var $web = "";
      var $phone = "";
      var $fax = "";
      var $bank = "";
      var $account_name = "";
      var $bsb = "";
      var $account_number = "";
      var $item = "";
      var $description = "";
      var $amount = "";
 
      //Page header
      function init($row=NULL){
       $this->unique_id = str_pad($row->unique_id,5,0,STR_PAD_LEFT);
       $this->company_name = $row->company_name;
       $this->abn = $row->abn;
       $this->address1 = $row->address1;
       $this->address2 = $row->address2;
       $this->country = $row->state;
       $this->email = $row->email;
       $this->web = $row->web;
       $this->phone = $row->phone;
       $this->fax = $row->fax;
       $this->bank = $row->bank;
       $this->account_name = $row->account_name;
       $this->bsb = $row->bsb;
       $this->account_number = $row->account_number;
       $this->item = $row->item;
       $this->description = $row->description;
       $this->amount = number_format($row->amount,2); 
       $this->gst = number_format(($this->amount/11),2);
      }
      //Page header
      function Header(){
       //Logo
       $this->Image('/images/pdf/logo.jpg',10,8,33);
       //Arial bold 15
       $this->SetFont('Arial','B',15);
       //Move to the right
       $this->Cell(140);
       //Title
       $this->Cell(40,10,'Tax Invoice',0,0,'R');
       //Arial normal 10
       $this->SetFont('Arial','',10);
       //Line break
       $this->Ln(20);
       //Address
       $this->Cell(40,10,$this->company_name,0,0,'L');
       //Line break
       $this->Ln(5);
       //Address
       $this->Cell(40,10,$this->address1,0,0,'L');
       //Line break
       $this->Ln(5);
       //Address
       $this->Cell(40,10,$this->address2,0,0,'L');
 
       //Move to the right
       $this->Cell(60);
       $this->SetFont('Arial','',7);
       $this->SetFillColor(250,250,250);
       //Title
       $this->Cell(35,5,'TAX REG No.',1,0,'L','1');
       //Title
       $this->Cell(25,5,'DATE',1,0,'L','1');
       //Title
       $this->Cell(35,5,'INVOICE No.',1,0,'L','1');
 
         $this->SetFont('Arial','',10);
        //Line break
       $this->Ln(5);
       //Address
       $this->Cell(40,10,$this->country,0,0,'L');
 
       //Move to the right
       $this->Cell(60);
       //Title
       $this->Cell(35,8,$this->abn,1,0,'L','0');
       //Title
       $this->Cell(25,8,date("d/m/Y"),1,0,'L','0');
       //Title
       $this->Cell(35,8,$this->unique_id,1,0,'L','0');
 
       //Line break
       $this->Ln(10);
       //Address
       $this->Cell(40,10,"Email: " . $this->email,0,0,'L');
       //Line break
       $this->Ln(5);
       //Address
       $this->Cell(40,10,"Web: " . $this->web,0,0,'L');
      }
     }
//instatiate it and create your pdf page
$pdf=new PDF();
      $pdf->init($invoice_row);
      $pdf->AddPage();
      $pdf->Ln(15);
      $pdf->SetFillColor(250,250,250);
      $pdf->SetFont('Arial','',6);
      $pdf->Cell(80,5,"INVOICE TO",1,0,'L','1');
      $pdf->Cell(20,5);
      $pdf->Cell(60,9,"TERMS",1,0,'C','1');
      $pdf->Cell(35,9,"DUE DATE",1,0,'C','1');
      $pdf->Ln(5);
      $pdf->SetFont('Arial','',8);
      $pdf->Cell(80,5,$name,"LR",0,'L','0');
      $pdf->Ln(4);
      $pdf->Cell(80,5,$company_name,"LR",0,'L','0');
      $pdf->Cell(20,5);
      $pdf->Cell(60,5,"Payment Immediate",1,0,'C','0');
      $pdf->Cell(35,5,date("d/m/Y"),1,0,'C','0');
      $pdf->Ln(5);
      $pdf->Cell(80,5,$address1,"LR",0,'L','0');
      $pdf->Ln(4);
      $pdf->Cell(80,5,$suburb . ", " . $postcode,"LR",0,'L','0');
      $pdf->Cell(20,5);
      $pdf->SetFont('Arial','',6);
      $pdf->Cell(60,9,"PAYMENT METHOD",1,0,'C','0');
      $pdf->Cell(35,9,"DIRECT DEPOSIT",1,0,'C','0');
      $pdf->SetFont('Arial','',8);
      $pdf->Ln(4);
      $pdf->Cell(80,5,$state,"LBR",0,'L','0');
      if ($_POST['promotion'] != ''){
       $pdf->Ln(7);
       $pdf->Cell(60,9,"PROMOTION CODE USED: " . $_POST['promotion'],1,0,'L','0');
       $pdf->Ln(8);
      }else{
       $pdf->Ln(15);
      }
      $pdf->SetFont('Arial','',6);
      $pdf->Cell(30,7,"ITEM",1,0,'C','1');
      $pdf->Cell(90,7,"DESCRIPTION",1,0,'C','1');
      $pdf->Cell(25,7,"TAX",1,0,'C','1');
      $pdf->Cell(25,7,"TAX AMT",1,0,'C','1');
      $pdf->Cell(25,7,"AMOUNT",1,0,'C','1');
      $pdf->SetFont('Arial','',8);
      $pdf->Ln(7);
      $pdf->Cell(30,5,$pdf->item,"1",0,'L','0');
      $pdf->Cell(90,5,$pdf->description,"1",0,'L','0');
      $pdf->Cell(25,5,"GST","1",0,'C','0');
      $pdf->Cell(25,5,"$" . $pdf->gst,"1",0,'R','0');
      $pdf->Cell(25,5,"$" . $pdf->amount,"1",0,'R','0');
      $pdf->Ln(5);
      $pdf->SetFont('Arial','',6);
      $pdf->Cell(90,7,"TAX SUMMARY",1,0,'L','1');
      $pdf->Cell(55,7);
      $pdf->Cell(25,7,"SUBTOTAL","LTB",0,'L','1');
      $pdf->Cell(25,7,"$" . $pdf->amount,"RTB",0,'R','1');
      $pdf->Ln(7);
      $pdf->SetFont('Arial','',6);
      $pdf->Cell(90,7,"$" . $pdf->gst . " GST",1,0,'R','1');
      $pdf->Cell(55,7);
      $pdf->Cell(25,7,"TAX TOTAL","LTB",0,'L','1');
      $pdf->Cell(25,7,"$" . $pdf->gst,"RTB",0,'R','1');
      $pdf->Ln(7);
      $pdf->SetFont('Arial','',6);
      $pdf->Cell(90,7,"Thank you for your business",1,0,'L','1');
      $pdf->Cell(55,7);
      $pdf->Cell(25,7,"TOTAL","LTB",0,'L','1');
      $pdf->Cell(25,7,"$" . $pdf->amount,"RTB",0,'R','1');
      $pdf->Ln(15);
      $pdf->SetFont('Arial','B',10);
      $pdf->Cell(90,7,"Payment Information",0,0,'L','0');
      $pdf->Ln(5);
      $pdf->Cell(20,5,"So we can track your payment, please use the invoice number",0,0,'L');
      $pdf->Ln(4);
      $pdf->Cell(20,5,"above and your business name as a reference when paying us",0,0,'L');
      $pdf->Ln(5);
      $pdf->Cell(90,7,"Direct Deposit to:",0,0,'L','0');
      $pdf->Ln(4);
      $pdf->Cell(90,7,$pdf->bank,0,0,'L','0');
      $pdf->Ln(4);
      $pdf->Cell(90,7,"Acc. Name: " .$pdf->account_name,0,0,'L','0');
      $pdf->Ln(4);
      $pdf->Cell(90,7,"BSB: " .$pdf->bsb,0,0,'L','0');
      $pdf->Ln(4);
      $pdf->Cell(90,7,"Acc. No: " .$pdf->account_number,0,0,'L','0');
      $pdf->Output("somefile.pdf");
__________________
Dash Digital - Inductor Development & Digital Manager
Reply With Quote
  #12  
Old 30-06-2009, 09:51 AM
patricktt's Avatar
patricktt patricktt is offline
Senior Member
AWIA Member
 
Join Date: May 2009
Location: Waroona, WA, Australia
Posts: 341
patricktt is on a distinguished road
Default

the thing with fpdf is that it can take a while to get everything looking like you want it, because you have to program how you want it to output the pdf.. which if you have the html already on screen, can double your time..

the good thing with dompdf is that you provide it with the html page and it does the rest for you..
__________________
Templeman Twells
Reply With Quote
  #13  
Old 30-06-2009, 10:02 AM
Vee Vee is offline
Senior Member
AWIA Member
 
Join Date: Jul 2008
Location: Mandurah, WA
Posts: 424
Vee is on a distinguished road
Default

Thanks Steve
Reply With Quote
  #14  
Old 30-06-2009, 10:11 AM
::Scott::'s Avatar
::Scott:: ::Scott:: is offline
Member
AWIA Member
 
Join Date: Jun 2009
Location: Brisbane Australia
Posts: 46
::Scott:: is on a distinguished road
Default

Quote:
Originally Posted by patricktt View Post
I have used dompdf quite a bit and recommend it, it's very easy to use and the results are impressive
+1 for dompdf! I use it and its great!
Reply With Quote
  #15  
Old 30-06-2009, 10:35 AM
stevebramley's Avatar
stevebramley stevebramley is offline
Senior Member
AWIA Member
 
Join Date: Jun 2006
Location: Applecross, Perth
Age: 42
Posts: 177
stevebramley is on a distinguished road
Default

awsome folks, I'll check it out! yeah it wasn't available when I did my pdf foray and I totally agree with the agony of painstakingly laying out the pdf by hand! No good.
__________________
Dash Digital - Inductor Development & Digital Manager
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +8. The time now is 12:26 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.