Introduction

Invoicr is a simple PHP class to generate beautifully designed invoices, quotes or orders with just a few lines of code. Brand it with your own logo and theme color, add unlimited items and total rows with automatic paging. You can deliver the PDF ouput in the user's browser, save on the server or force a file download.

Multi-languages & currencies

Invoicr has built in translations in English, Dutch, French, German, Spanish and Italian (you can easily add your own if needed) and you can set the currency needed per document.

Additional titles, paragraphs and badges

We made it easy to add extra content (titles and multi-line paragraphs) to the bottom of the document. You might use it for payment or shipping information or any other content needed.


Getting Started

Installation

Upload the invoicr folder and all content to your webserver.

Examples

There are 3 examples included in the class that work out of the box.
Surf to http://[yourwebsite]/invoicer/examples/filename.php to view them.
- invato.php
- apple.php
- soundcloud.php


Create a new invoice

Create a new php file in the root of your webserver and include the class to get started.
Please make sure that the default php date timezone is set before including the class.
Click here for more information.

In this simple example we are generating an invoice with custom logo and theme color.
It will contain 2 products and a box on the bottom with VAT and total price. Then we add a "Paid" badge right before the output.

<?php
//Set default date timezone
date_default_timezone_set('America/Los_Angeles');
//Include Invoicr class
include('invoicr/invoicr.php');
//Create a new instance
$invoice = new invoicr("A4","$","en");
//Set number formatting
$invoice->setNumberFormat('.',',');
//Set your logo
$invoice->setLogo("invoicr/examples/images/envato.png");
//Set theme color
$invoice->setColor("#82b541");
//Set type
$invoice->setType("Invoice");
//Set reference
$invoice->setReference("20140904001");
//Set date
$invoice->setDate("01.01.2014");
//Set due date
$invoice->setDue("03.01.2014");
//Set from
$invoice->setFrom(array("Envato Inc","4146 Golden Hickory Woods","Glass Hill, Sydney","Australia","VAT 377 855 846"));
//Set to
$invoice->setTo(array("EpicBrands Studios","1516 Holt Street","West Palm Beach","FL 33401 - USA","VAT 148 366 032"));
//Add items
$invoice->addItem("Wordpress theme",false,2,"21%",9.99,false,19.98);
$invoice->addItem("Php invoicr class","Lorem ipsum dolor sit amet, consectetur adipiscing elit.\nDuis sodales, lorem quis aliquam sollicitudin, metus risus dignissim lorem.",1,"21%",4.95,false,4.95);
//Add totals
$invoice->addTotal("Total",24.93);
$invoice->addTotal("VAT 21%",5.23);
$invoice->addTotal("Total due",30.16,true);
//Add Badge
$invoice->addBadge("paid");
//Add Title
$invoice->addTitle("Payment information");
//Add Paragraph
$invoice->addParagraph("Make all cheques payable to Envato Inc.\nIf you have any questions concerning this invoice, contact our sales department at sales@envato.com.\n\nThank you for your business.");
//Set footer note
$invoice->setFooternote("http://www.envato.com");
//Render the PDF
$invoice->render('Envato.pdf','I');
?>
		

Documentation

See and learn how every Invoicr method works in detail

Create instance

Start a new instance of the Invoicr class.

$invoice = new invoicr(size,currency,language);
  • size {string} Set your document size.
    • A4Default
    • Letter
    • Legal
  • currency {string} Set the currency that you want to use by simply passing the currency symbol as a string. (e.g. "$")
  • language {string} Select a language that exists in the /languages folder. Create your own translation file or use the included:
    • EN (English)Default
    • NL (Dutch)
    • FR (French)
    • DE (German)
    • ES (Spanish)
    • IT (Italian)

Number formatting

How do you want to show your numbers?

$invoice->setNumberFormat(decimalpoint,seperator);
  • decimalpoint {string} Specifies what string to use for decimal point. Commonly used is '.' or ','
  • seperator {string} Specifies what string to use for thousands separator. Commonly used is '.' or ','

Theme color

Set a custom color to personalize your invoices.

$invoice->setColor(color);
  • color {string} Hexadecimal color code. Example for red: '#FF0000'

Logo

Add your company logo to the invoice.

$invoice->setLogo(image,maxwidth,maxheight);
  • image {string} Local path or remote url of the image file to be used, preferably a good quality transparant png image.
  • maxwidth {int}Optional Set the width (in mm) of the bounding box where the image will be fitted in. Maxheight parameter is required.
  • maxheight {int}Optional Set the height (in mm) of the bounding box where the image will be fitted in. Maxwidth parameter is required.

Document type

Set the type of document you are creating.

$invoice->setType(type);
  • type {string} A string with the document type. that will be used for the title in the right top corner of the document (e.g. 'invoice' or 'quote')

Reference

Add your document reference or number

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

Date

Set your document date.

$invoice->setDate(date);
  • date {string} A string with the document's date (e.g. '').

Due DateOptional

Set your invoice due date.

$invoice->setDue(duedate);
  • duedate {string} A string with the document's due date (e.g. '')

Company information

Set your company details.

$invoice->setFrom(company);
  • company {array} An array with your company details. The first value of the array will be bold on the document so we suggest you to use your company's name. You can add as many lines as you need.

    Example:
    array('My Company','Address line 1','Address line 2','City and zip','Country','VAT number');

Client information

Set your client details.

$invoice->setTo(client);
  • client {array} An array with your clients' details. The first value of the array will be bold on the document so we suggest you to use your company's name. You can add as many lines as you need.

    Example:
    array('My Client','Address line 1','Address line 2','City and zip','Country','VAT number');

FlipFlopOptional

Switch the horizontal positions of your company information and the client information. By default, your company details are on the left.

$invoice->flipflop();

Add item

Add a new product or service row to your document below the company and client information. Invoicr has automatic paging so there is absolutely no limit.

$invoice->addItem(name,description,amount,vat,price,discount,total);
  • name {string} A string with the product or service name.
  • description {string} A string with the description with multi-line support. Use either <br> or \n to add a line-break.
  • amount {decimal} An integer with the amount of this item.
  • vat {string} or {decimal} Pass a string (e.g. "21%", or any other text you may like) or a decimal if you want to show an amount instead (e.g. 124.30)
  • price {decimal} A decimal for the unit price.
  • discount {string}, {decimal} or {boolean}Optional Pass a string (e.g. "10%", or any other text you may like) or a decimal if you want to show an amount instead (e.g. 50.00) If you do not want to give discount just enter the boolean false in this field. Note: the final output will not show a discount column when all of the products haven't set a discount.
  • total {decimal} A decimal for the total product or service price.

Add Total

Add a row below the products and services for calculations and totals. You can add unlimited rows.

$invoice->addTotal(name,value,background);
  • name {string} A string for the display name of the total field.
  • value {decimal} A decimal for the value.
  • background {boolean}Optional Set to true to set the theme color as background color of the row.

Add badgeOptional

Adds a badge to your invoice below the products and services. You can use this for example to display that the invoice has been payed.

$invoice->addBadge(badge);
  • badge {string} A string with the text of the badge.

Add title

You can add titles and paragraphs to display information on the bottom part of your document such as payment details or shipping information.

$invoice->addTitle(title);
  • title {string} A string with the title to display in the badge.

Add paragraph

You can add titles and paragraphs to display information on the bottom part of your document such as payment details or shipping information.

$invoice->addParagraph(paragraph);
  • Paragraph {string} A string with the paragraph text with multi-line support. Use either <br> or \n to add a line-break.

Footer

A small text you want to display on the bottom left corner of the document.

$invoice->setFooternote(note);
  • note {string} A string with the information you want to display in the footer.

Render

Render the invoice.

$invoice->render(name,output);
  • name {string} A string with the name of your invoice.
    Example: 'invoice.pdf'
  • output {string} Choose how you want the invoice to be delivered to the user. The following options are available:
    • I (Send the file inline to the browser)
    • D (Send to the browser and force a file download with the name given by name)
    • F (Save to a local file. Make sure to set pass the path in the name parameter)
    • S (Return the document as a string)

Credits

We would like to thank the creators of FPDF to create such an amazing PHP library that makes our work a lot easier.
http://www.fpdf.org/