Difference between revisions of "PDF Invoice Customisation"
m (→Editing Text & Content) |
(→Additional Fonts) |
||
Line 58: | Line 58: | ||
==Additional Fonts== | ==Additional Fonts== | ||
− | If you use certain special characters, they may not be covered by the standard font and so here is an alternative font type that supports Czech, Russian, Arabic & persian among others. To install simply download the font files from the URL below, upload into the '''/includes/fonts/''' folder and then activate and specify the custom font name '''dejavusans''' in '''Setup > General Settings > Invoices > TCPDF Font''' | + | If you use certain special characters, they may not be covered by the standard font and so here is an alternative font type that supports Czech, Russian, Arabic & persian among others. To install simply download the font files from the URL below, upload into the '''/includes/fonts/''' folder (v5.3.1 and below) or the '''/includes/classes/TCPDF/fonts/''' folder (v5.3.2 and later) and then activate and specify the custom font name '''dejavusans''' in '''Setup > General Settings > Invoices > TCPDF Font''' |
http://www.whmcs.com/members/dl.php?type=d&id=106 | http://www.whmcs.com/members/dl.php?type=d&id=106 | ||
− | |||
==Accented Characters== | ==Accented Characters== | ||
Due to a limitation in PHP you may find the translations of the "Paid" and "Unpaid" text on the PDF Invoices do not display upper-case accented characters correctly. To resolve this please refer to http://forum.whmcs.com/showthread.php?t=45594 | Due to a limitation in PHP you may find the translations of the "Paid" and "Unpaid" text on the PDF Invoices do not display upper-case accented characters correctly. To resolve this please refer to http://forum.whmcs.com/showthread.php?t=45594 |
Revision as of 19:50, 7 February 2014
There are 2 invoice templates - one for the client area invoice and another for the PDF version of an invoice. These have the filenames viewinvoice.tpl and invoicepdf.tpl respectively and can be found in your active WHMCS template folder.
Contents
Modifying the Logo
The logo displayed on the PDF invoices is located in the images folder. To change this to your own logo simply upload your logo to the images folder and name it "logo.jpg" or "logo.png"
You can change the width of the logo image in the invoicepdf.tpl template file. On line 4, just adjust the last number "75" before the closing bracket ); on that line, this variable defines the image width. You can then experiment increasing and decreasing it until happy.
Editing Text & Content
You can fully customize the PDF invoices such as adding or removing text, altering the layout or adding furthur images & formatting. This is done by editing the template file invoicepdf.tpl in your active template folder. The file contains all the code relating to the layout and display of the invoice in its PDF format. You will need a basic working knowledge of PHP coding in order to understand and modify the file.
The PDF's are generated using TCPDF & you can find a full list of available functions to help you build your template @ http://www.tcpdf.org/doc/code/classTCPDF.html
Displaying Custom Fields
As of version 4.5 custom fields can be displayed on the printable and PDF invoices by ticking the Setup > Custom Client Fields > Show on Invoice option.
Available Variables
The following variables are available for use in the invoicepdf.tpl file and further data can be obtained by running SQL queries directly from within the template which does allow custom PHP code to be executed.
- $datecreated - The date the invoice was created
- $duedate - The date the invoice is due
- $datepaid - Shows paid date/time if invoice is set to Paid
- $userid - Client ID Number
- $clientsdetails["firstname"] - Client Info First Name
- $clientsdetails["lastname"] - Client Info Last Name
- $clientsdetails["companyname"] - Client Info Company Name
- $clientsdetails["fieldname"] - etc...
- $clientsdetails["customfields1"] - Client Info Custom Field #1
- $subtotal
- $tax
- $taxrate
- $credit
- $total
- $status - Paid, Unpaid or Cancelled
- $paymentmethod
- $notes
- $companyname - Your Company Name
- $companyurl - Your Default Website URL
- $companyaddress - Your Company Address
- $invoiceitems - Array of invoice items
Changing/Translating Filename
As standard the filename for invoices is Invoice-xxx and for quotes Quote-xxx where xxx is the ID of the invoice or quote. It may be desirable to change the filenames your clients see or translate into other languages. This is achieved in the same way as any text within WHMCS, through the Language Files, specifically the strings:
$_LANG['invoicefilename'] = "Invoice-"; $_LANG['quotefilename'] = "Quote-";
Reducing the Filesize of PDFs
The bulk of the file size of the PDFs that are generated by WHMCS come from the embedding of the font files for the UTF-8 character set. Because the UTF-8 charset has a large range of characters it supports, this means it takes up much more space than say the iso-8859-1 charset which unlike UTF-8, only supports A-Z 0-9 and other standard characters.
Therefore if you don't need all those special characters UTF-8 supports (ie. you don't have clients using those characters in their names/addresses) then you can reduce the filesize of PDF's quite considerably by changing the font. To do that, simply go to Setup > General Settings > Invoices > TCPDF Font and change the selection from "Freesans" to "Helvetica"
Additional Fonts
If you use certain special characters, they may not be covered by the standard font and so here is an alternative font type that supports Czech, Russian, Arabic & persian among others. To install simply download the font files from the URL below, upload into the /includes/fonts/ folder (v5.3.1 and below) or the /includes/classes/TCPDF/fonts/ folder (v5.3.2 and later) and then activate and specify the custom font name dejavusans in Setup > General Settings > Invoices > TCPDF Font
http://www.whmcs.com/members/dl.php?type=d&id=106
Accented Characters
Due to a limitation in PHP you may find the translations of the "Paid" and "Unpaid" text on the PDF Invoices do not display upper-case accented characters correctly. To resolve this please refer to http://forum.whmcs.com/showthread.php?t=45594