Introduction
Recently, I had to make amendments to the Dolibarr CRM Invoice design and text. At first glance, it seemed too hard to manage. However, after some research, I found that there are two primary ways to change an invoice:
- Option 1: Changing the ODT file.
- Option 2: Changing the PHP code directly.
Being a PHP professional, I chose the PHP way. I have learned a lot of things that can be modified easily, so I thought I would share this guide for others willing to change the Dolibarr invoice.
Getting Started: The File You Need
All you need to do is make changes in one specific PHP file. Navigate to the following path on your server:
How to Change Date Format
One of the first changes I made was changing the Date format of the Invoice from MM/DD/YYYY to DD/MM/YYYY.
To do so, I defined my own function:
Then, I replaced the original output line and added my defined function to wrap the date output:
How to Change Specific Text
Anything written between $outputlangs->transnoentities is the output that is going to print. You can identify the correct text string and replace it directly in the code.
How to Insert New Text
You can use the MultiCell method to insert any custom text you need.
Formatting, Styling & Layout
Setting Font Size
To change the font size of text in the invoice, use the SetFont method. You can subtract or add to the default size variable.
Drawing a Rectangle
You can draw a rectangle using the following parameters:
The parameters represent: X Coordinates, Y Coordinates, Width, and Height.
Setting Position (X, Y)
To move the cursor to a specific position before writing text:
Filling Color
To fill a particular area with color (values are in RGB format):
Setting Text Color
To change the text color (values are in RGB format):