PHP code example of saidrmdhani / pdf-invoice

1. Go to this page and download the library: Download saidrmdhani/pdf-invoice library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

saidrmdhani / pdf-invoice example snippets


use Konekt\PdfInvoice\InvoicePrinter;

  $invoice = new InvoicePrinter();
  
  /* Header settings */
  $invoice->setLogo("images/sample1.jpg");   //logo image path
  $invoice->setColor("#007fff");      // pdf color scheme
  $invoice->setType("Sale Invoice");    // Invoice Type
  $invoice->setReference("INV-55033645");   // Reference
  $invoice->setDate(date('M dS ,Y',time()));   //Billing Date
  $invoice->setTime(date('h:i:s A',time()));   //Billing Time
  $invoice->setDue(date('M dS ,Y',strtotime('+3 months')));    // Due Date
  $invoice->setFrom(array("Seller Name","Sample Company Name","128 AA Juanita Ave","Glendora , CA 91740"));
  $invoice->setTo(array("Purchaser Name","Sample Company Name","128 AA Juanita Ave","Glendora , CA 91740"));
  
  $invoice->addItem("AMD Athlon X2DC-7450","2.4GHz/1GB/160GB/SMP-DVD/VB",6,0,580,0,3480);
  $invoice->addItem("PDC-E5300","2.6GHz/1GB/320GB/SMP-DVD/FDD/VB",4,0,645,0,2580);
  $invoice->addItem('LG 18.5" WLCD',"",10,0,230,0,2300);
  $invoice->addItem("HP LaserJet 5200","",1,0,1100,0,1100);
  
  $invoice->addTotal("Total",9460);
  $invoice->addTotal("VAT 21%",1986.6);
  $invoice->addTotal("Total due",11446.6,true);
  
  $invoice->addBadge("Payment Paid");
  
  $invoice->addTitle("Important Notice");
  
  $invoice->addParagraph("No item will be replaced or refunded if you don't have the invoice with you.");
  
  $invoice->setFooternote("My Company Name Here");
  
  $invoice->render('example1.pdf','I'); 
  /* I => Display on browser, D => Force Download, F => local path save, S => return document as string */

use Konekt\PdfInvoice\InvoicePrinter;

// Default Param: Size: A4, Currency: $, Language: en
$invoice = new InvoicePrinter($size, $currency, $language); 

$invoice->setNumberFormat($decimalpoint, $seperator, $alignment, $space, $negativeParenthesis);

// Hexadecimal color code
$invoice->setColor($color);

$invoice->setLogo($image, $maxwidth, $maxheight);

// A string with the document title, will be displayed
// in the right top corner of the document (e.g. 'Invoice' or 'Quote')
$invoice->setType($title);

// Document reference number that will be displayed in
// the right top corner of the document (e.g. 'INV29782')
$invoice->setReference($number);

//A string with the document's date
$invoice->setDate($date);

// A string with the document's due date
$invoice->setDue($duedate);

// An array with your company details. The first value of
// the array will be bold on the document so it's suggested
// to use your company's name. You can add as
// many lines as you need.
/** Example: */
$invoice->setFrom([
    'My Company',
    'Address line 1',
    'Address line 2',
    'City and zip',
    'Country',
    'VAT number'    
]);

// An array with your clients' details. The first value of the
// array will be bold on the document so we suggest you to use
// the company's name. You can add as many lines as you need.
/** Example */
$invoice->setTo([
   'My Client',
   'Address line 1',
   'Address line 2',
   'City and zip',
   'Country',
   'VAT number'    
]);

$invoice->flipflop();

$invoice->hideToFromHeaders();

$invoice->addItem(name,description,amount,vat,price,discount,total);

$invoice->setFontSizeProductDescription(9);

$invoice->addTotal(name,value,background);

$invoice->addBadge($badge);

$invoice->addBadge('Paid', '#00ff00');
// Short hex variant is also supported
$invoice->addBadge('Payment pending', '#f00');

$invoice->addTitle($title);

$invoice->addParagraph($paragraph);

$invoice->changeLanguageTerm($term, $new);
$invoice->changeLanguageTerm('date', 'Confirmation Date');

$invoice->setFooternote($note);

$invoice->render($name, $output);