Home / Blog / Software Development

Software Development

How to Modify Dolibarr Invoices

Need to change the design or text of a Dolibarr invoice? You can edit the ODT template or the PHP code. This guide shows the PHP route.

In this article
  1. The file
  2. Date format
  3. Change text
  4. Styling
  5. Keep changes safe
  6. Frequently asked questions

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.

The Ucodice Team is a group of passionate developers, designers and strategists delivering web, mobile and software solutions to clients worldwide.

Ready to take the next step?

Explore our all ucodice services or tell us about your project. A senior member of our team will get back to you with clear next steps.

Let's start your project

Tell us what you want to build or grow. We'll reply within one business day with clear next steps.

Phone: 9560430495  ·  Email: contact@ucodice.com

Office: Ucodice Technologies, IHDP Business Park, Street Number 7, Sector 127, Noida, Uttar Pradesh 201304. Also serving Delhi NCR and clients worldwide.

Trusted and certified

  • Google PartnerCertified for Google Ads
  • Meta business PartnerCertified for Meta Ads
  • 4.3 / 5 on Google47 Google reviews
  • 4.9 / 5 on Freelancer.in245 reviews

Free consultation

Tell us about your project.

Get a free quote