Dolibarr is an open-source ERP and CRM. When we needed to change the design and text of its invoices, there were two options: edit the ODT template file, or edit the PHP code directly. As PHP developers, we chose the PHP route, and this guide shares what we learned.
Key takeaways
- Invoice PDFs are generated by a PHP file in the Dolibarr core.
- You can change dates, labels, fonts, colors and positions with a few functions.
- Back up the file before editing, because upgrades can overwrite it.
- Prefer a custom module or a copy of the template so updates do not erase your work.
Getting started: the file you need
All the changes are made in one PHP file. On our server it was:
/public_html/db/core/modules/facture/doc/pdf_crabe.modules.php
The path depends on your installation. Make a backup copy before you edit it.
How to change the date format
To show dates as DD/MM/YYYY instead of MM/DD/YYYY, write a small helper that swaps the first two parts, and wrap the existing date output in it:
function _changeDateFormat($date) {
$parts = explode("/", $date);
return $parts[1] . "/" . $parts[0] . "/" . $parts[2];
}
This assumes the date always has three parts separated by slashes.
How to change or insert text
Text passed to $outputlangs->transnoentities is what gets printed, so to change a label, find its string in the code and replace it. To add new text, use the MultiCell method:
$pdf->MultiCell($widthrecbox, 5, "Your Text Here", 0, 'L');
Formatting, styling and layout
Font size
$pdf->SetFont('', '', $default_font_size - 1);
Draw a rectangle
The four parameters are the X position, Y position, width and height.
$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
Set the position
$pdf->SetXY($posx+2, $posy-5);
Fill and text colors
$pdf->SetFillColor(224, 224, 224);
$pdf->SetTextColor(0, 0, 60);
Keep your changes safe
Core files are overwritten when you upgrade Dolibarr. Keep a copy of your changes, or move them into a custom module. If you need a tailored ERP or CRM solution, see our custom software development services.
Frequently asked questions
Can I change the invoice without editing PHP?
Yes. Dolibarr also supports ODT templates, which you can edit in a word processor.
Will my changes survive an upgrade?
Not if you edit the core file. Keep a backup or use a custom module so you can re-apply them.



