Jun
30
2009

PHP pdf invoice

I need for my cms a class that can print invoice payment in pdf format.

Wel I find a nice script for oscommerce ( http://www.oscommerce.com/community/contributions,5321/category,12/search,pdf_customer_invoice ) that have a nice view of  the pdf invoice; Than I port this script and make a class for use in all indipendent cms …

Here can download the example output of the invoice class:

Ininvoice pdf

download

Size: 81.96 KB
Hits : 68


Here is an example of use:

<?php
$dir = dirname(__FILE__).'/';
define('FPDF_FONTPATH', $dir.'font/');
include($dir.'fpdf.php');
include($dir.'cat-pdf-invoice.inc.php');

$pdf = new Pdf_Invoice(array('locale'=>false,'lang'=>'en','show_watermark'=>true,'watermark_text'=>'Invoice copy'));
$params = array(
'customer_id'=>1,
'payment_method'=>'Paypal',
'carrier_method'=>'Flat rate',
'carrier_price'=>5.25,
'order_id'=>222,
'order_date'=>'2009/02/11',
'invoice_address'=>"street name\ncity zip\nstate\ncountry\n",
'delivery_address'=>"street name\ncity zip\nstate\ncountry\n",
'store_name'=>'My store name',
'store_address'=>"store street name\nstore city zip\nstore state\nstore country\n",
'store_tel'=>'+39 011222222',
'store_fax'=>'+39 011333333',
'store_email'=>'info@mystore.com',
'store_web'=>'http://mystore.com',
'store_tax_number'=>87039097397390,
'img_logo'=>$dir.'invoice-logo.jpg',
'img_logo_correction'=>0.18,
'invoice_footer'=>'Thank you for your purchase'
);
$pdf->SetInvoiceParams($params);

$product = array(
'qty'=>2,
'name'=>'product 1 name',
'model'=>'product 1 model',
'attributes'=>'color: red, size: xl',
'price'=>23.00,
'tax'=>20.00
);
$pdf->SetProduct($product);
$product = array(
'qty'=>10,
'name'=>'product 2 name',
'model'=>'product 2 model',
'attributes'=>'color: blue, size: xxl',
'price'=>13.00,
'tax'=>18.00
);
$pdf->SetProduct($product);
$product = array(
'qty'=>3,
'name'=>'product 3 name',
'model'=>'product 3 model',
'attributes'=>'color: blue, size: xxl',
'price'=>5.00,
'tax'=>18.00
);
$pdf->SetProduct($product);
$product = array(
'qty'=>10,
'name'=>'product 4 name',
'model'=>'product 4 model',
'attributes'=>'color: blue, size: xxl',
'price'=>90.00,
'tax'=>18.00
);
$pdf->SetProduct($product);
$product = array(
'qty'=>10,
'name'=>'product 5 name',
'model'=>'product 5 model',
'attributes'=>'color: blue, size: xxl',
'price'=>43.00,
'tax'=>22.00
);
$pdf->SetProduct($product);

$pdf->GetInvoice($dir.'lang/');
?>
Share and Enjoy:
  • Facebook
  • del.icio.us
  • Twitter
  • Google Bookmarks
  • Digg
  • Technorati
  • MySpace
  • Live
  • BlinkList
  • Add to favorites
  • email
  • RSS
  • Mixx
  • Bitacoras.com
  • blogmarks
  • Blogosphere News
  • Blogplay
  • connotea
  • Current
  • Diggita
  • Diigo
  • DZone
  • eKudos
  • Internetmedia
  • LinkedIn
  • MSN Reporter
  • Reddit
  • Scoopeo
  • Segnalo
  • Slashdot
  • Socialogs
  • Sphinn
Written by Davide in: Library, php | Tags: , , , ,

No Comments »

RSS feed for comments on this post. TrackBack URL

Leave a comment

Theme: TheBuckmaker.com Magazine Style Templates