Article ID: 9604, created on Jan 21, 2011, last review on May 10, 2014

  • Applies to:
  • Plesk 10.1 for Linux/Unix
  • Plesk 10.1 for Windows


I require more flexibility in customization of PDF invoices. The GUI settings (System > System configuration > PDF Customization) do not suffice.


The system generates PDF invoices by means of a script you can tailor to your needs. Modify this file to change document layout, format and content. The default location of the script is:

On Linux - /opt/plesk-billing/lib-billing/include/config/PDFInvoice.php
On Windows - C:\Program Files\Parallels\Plesk\billing\htdocs\lib-billing\include\config\PDFInvoice.php

We suppose that you have sufficient PHP programming skills and experience with TCPDF and FPDI libraries to modify the script.
Parallels Customer & Business Manager will invoke this script with parameters stored in the constructor variable $args. These parameters include:
  • (mandatory) invoice. Object of the Invoice type that stands for the invoice to be generated.
  • (mandatory) issuerCompany. Object of the Company type containing information about your company.
  • (mandatory) configParams. Array of parameters from the “PDF Invoice Customization” page in format 'name' => 'value'. These parameters include "invoice_title", "header_align", "measurement_unit", "horizontal_size", "vertical_size", "horizontal_indent", "vertical_indent", "font_size", "tax_id_title", "header_align", "tax_included_title", "sale_terms", "custom_footer", "invoice_logo" and "show_invoice_logo".
  • (mandatory) transactions. Array of Transaction objects associated with the invoice.
  • (mandatory) issuerLocale. String containing a locale name of the Business Manager Administrator.
  • (mandatory) userLocale. String containing a customer locale name.
  • stationeryPdfFile. String that defines a path to a stationery PDF page template. The system uses this template to define invoice page style (logos, watermarks, preprinted labels).
  • certificate. Object of the Certificate type (optional) – use this parameter to create a digital signature of the created invoice.
Methods of class PDFInvoice are responsible for the following actions:
  • Constructor. Controller of the PDF file generation process; accepts $args parameters to generate invoice.
  • Header. Applies a template set by the stationeryPdfFile parameter to every page.
  • getDefaultFont. Returns a font according to the Business Manager locale.
  • getDefaultFontSize. Returns a document font size.
  • addLogo. Renders a logo from invoice_logoparameter if the value of invoice_show_logo is true.
  • addSenderInfo. Renders sender postal information from issuerCompany parameter.
  • addSenderAdditionalInfo. Renders sender additional information (VAT number, phone number and email, etc.).
  • addCustomerInfo. Renders customer postal information from the invoice parameter. The position where to output this information is identified by a set of parameters and method initAddressOptions.
  • addCustomerAdditionalInfo. Renders customer additional information (f.e., VAT number).
  • addInvoiceData. Renders general invoice data as invoice number, dates, etc.
  • addInvoiceTitle. Renders the invoice title.
  • addBillingPoint. Renders the current date and minimal contract term.
  • addItems, addOneItem, addAddons, addOneAddon. Set of methods to render invoice items as a table.
  • addTotals. Renders “Totals” .
  • addPayments, addOnePayment. Set of methods to render the “Payments” section.
  • addSaleTerms. Renders sales terms from each sale_termsitem in configParams parameter.
  • addCustomFooter. Renders footer from custom_footer item in configParams parameter.
  • initAddressOptions. Calculates the position of the address block.
Use the database scheme as a reference because all objects have properties that are equal to database fields, for example:

$invoiceNumber = $invoice->invoice_number; // number of invoice

Use the following syntax to get access to database-related objects:

$client = $invoice->Client; // customer
$invoiceLineItems = $invoice->InvoiceLineItemList(); // array of InvoiceLineItem objects
foreach ($invoiceLineItems as $invoiceLineItem) {
  if (0 == $invoiceLineItem->package_addon_id) {
    // $invoiceLineItem is subscription item
    $subscription = $invoiceLineItem->Package; // subscription - object of Package type
    $subscription_attributes = $subscription->PackageAttributesList(); // array of PackageAttributes objects
  } else {
    // $invoiceLineItem is subscription add-on item
    $subscription_addons = $invoiceLineItem->Package->PackageAddonList() // array of PackageAddon objects

Pay attention that not all properties in the object must be initialized. Use the following construction to perform a check and to access BillingAccount objects inside the Transaction object:

if ($transaction->billing_account_id > 0) {
  //you can access object of ClientBillingAccount type
  $billingAccount = $transaction->BillingAccount;

Use the following syntax to get access to customer attributes:

$attribute_id = 4;
$attribule_value = $invoice->Client->ClientAttributes[$attribute_id]->client_attribute_value;

df2db7f3302fe384002b885ca84f1a2f a914db3fdc7a53ddcfd1b2db8f5a1b9c 85a92ca67f2200d36506862eaa6ed6b8 c796c01d6951fa24ed54c7f1111667c6 def31538ba607bde27398f48ab5956be 29d1e90fd304f01e6420fbe60f66f838 dd0611b6086474193d9bf78e2b293040 56797cefb1efc9130f7c48a7d1db0f0c

Email subscription for changes to this article
Save as PDF