• Online Demo
  • 30-day Free Trial

For simple customizations, such as changing the background or editing the logo see the Invoices section of this manual.

Customizing Invoices


  • Note: This section only applies to version 2.1 or greater.

As of 2.1 you may now edit the code handling the creation of the invoice directly, through modifying /inc/invoice-pdf.class.php. This allows you to control all aspects of the invoice design and positioning of elements.

Required Methods

The invoice class must implement the InvoiceInterface. Below is the InvoiceInterface, which is already included in Blesta. All methods in the InvoiceInterface must be implemented.

interface InvoiceInterface {
    public function __construct($company_info);
    public function makeInvoice($inv_data); // generates an invoice file based on the given data
    public function fetch(); // returns the current invoice file
    public function stream(); // stream the current invoice file
}

When building the invoice Blesta first calls the constructor, passing your current company information. Next, the makeInvoice method is called whose single parameter is a multidimensional array of invoices and their data. If this is only a single invoice then the first dimension of this array contains only one element (the 0th element).

Finally, depending on the request type, Blesta will invoke the fetch() or stream() method. When sending invoices to the browser the stream method is called, for all other requests the fetch() method is called.

Modifying The Invoice Class

When modifying invoice-pdf.class.php the methods to take note of are drawInvoiceHeader, drawInvoiceFooter, and drawInvoice. From within makeInvoice, drawInvoice is invoked and an array containing the information of a single invoice is passed into the method. The drawInvoice method creates all pages and fills each page with a header, line items, and footer.