# Text on footer invoices easily

**URL:** <https://www.dolibarr.org/forum/t/text-on-footer-invoices-easily/24983>\
**Category:** Developing for Dolibarr\
**Created:** [February 19, 2024, 7:33pm UTC](https://www.dolibarr.org/forum/t/text-on-footer-invoices-easily/24983 "2024-02-19T19:33:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefgo3](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/s/3ec8ea/32.png) [@stefgo3](https://www.dolibarr.org/forum/u/stefgo3)\
**Post date:** [February 19, 2024, 7:33pm UTC](https://www.dolibarr.org/forum/t/text-on-footer-invoices-easily/24983/1 "2024-02-19T19:33:10Z")

</div>

Hello,

I searched, but I didn’t find anything, so here is a little code that will help you easily add a footer to your invoice.

You must create a “pied\_de\_page.txt” file in the main Dolibarr folder.

**Edit this file** : /core/lib/pdf.lib.php

**Find this line:**

`// Show page nb only on iso languages (so default Helvetica font)`

**Just above, add this code:**

```auto
$largeurDisponible = $dims['wk'] - $dims['lm'] - $dims['rm'];

// Vous pouvez changer le nom du fichier ici
$cheminFichier = DOL_DOCUMENT_ROOT.'/pied_de_page.txt'; 

if (file_exists($cheminFichier)) {
    $textePersonnalise = file_get_contents($cheminFichier);
} else {
    $textePersonnalise = "Le fichier pied_de_page.txt n'est pas trouvé.";
}

$pdf->SetXY($dims['lm'], -$posy - getDolGlobalInt('PDF_FOOTER_PAGE_NUMBER_Y', 0));

$pdf->MultiCell($largeurDisponible, 10, $textePersonnalise, 0, 'C', 0);

```

When you add text in txt file. Line changes will also be reproduced on the footer.

I hope this helped, if you want to improve, don’t hesitate.

---

<div class="post-metadata">

**Author:** ![jonbendtsen](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@jonbendtsen](https://www.dolibarr.org/forum/u/jonbendtsen)\
**Post date:** [February 19, 2024, 8:00pm UTC](https://www.dolibarr.org/forum/t/text-on-footer-invoices-easily/24983/2 "2024-02-19T20:00:39Z")

</div>

cool, do you have a picture with and without your footer?

Maybe also submit a pull request here [GitHub - Dolibarr/dolibarr: Dolibarr ERP CRM is a modern software package to manage your company or foundation's activity (contacts, suppliers, invoices, orders, stocks, agenda, accounting, ...). it's an open source Web application (written in PHP) designed for businesses of any sizes, foundations and freelancers.](https://github.com/Dolibarr/dolibarr)

---

<div class="post-metadata">

**Author:** ![stefgo3](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/s/3ec8ea/32.png) [@stefgo3](https://www.dolibarr.org/forum/u/stefgo3)\
**Post date:** [February 19, 2024, 10:14pm UTC](https://www.dolibarr.org/forum/t/text-on-footer-invoices-easily/24983/3 "2024-02-19T22:14:30Z")

</div>

This allows you to put text which will remain at the very bottom of the invoice and will not be superimposed if the invoice is very long.

I can’t put files (new user), so here is a link with the 2 images in Google drive

[https://drive.google.com/drive/folders/1xaXEF\_QT2Hs-bFmfRDf4-jdZywCsxDWJ?usp=sharing](https://drive.google.com/drive/folders/1xaXEF_QT2Hs-bFmfRDf4-jdZywCsxDWJ?usp=sharing)

---

<div class="post-metadata">

**Author:** ![jonbendtsen](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@jonbendtsen](https://www.dolibarr.org/forum/u/jonbendtsen)\
**Post date:** [February 19, 2024, 10:23pm UTC](https://www.dolibarr.org/forum/t/text-on-footer-invoices-easily/24983/4 "2024-02-19T22:23:35Z")

</div>

Text is in French so I can’t read it.

no-footer.jpg

 ![no-footer](https://www.dolibarr.org/forum/uploads/dolibarrorg/original/2X/5/57b10d1f0dbaf8f581060475f00e9c02aeed6c62.jpeg)

with footer.jpg

 ![with footer](https://www.dolibarr.org/forum/uploads/dolibarrorg/original/2X/c/c58079a77f5376144baa674e2b85ecc738dd8f14.jpeg)

I can’t use it as I already use the built in footer function that you can see in this picture:

 ![jons_footer](https://www.dolibarr.org/forum/uploads/dolibarrorg/original/2X/4/40e9bd94573eecd6d7b8b2df0e6d9163f5758155.png)

---

<div class="post-metadata">

**Author:** ![stefgo3](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/s/3ec8ea/32.png) [@stefgo3](https://www.dolibarr.org/forum/u/stefgo3)\
**Post date:** [February 19, 2024, 11:22pm UTC](https://www.dolibarr.org/forum/t/text-on-footer-invoices-easily/24983/5 "2024-02-19T23:22:28Z")

</div>

😳 where is this function?

---

<div class="post-metadata">

**Author:** ![jonbendtsen](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@jonbendtsen](https://www.dolibarr.org/forum/u/jonbendtsen)\
**Post date:** [February 20, 2024, 6:35am UTC](https://www.dolibarr.org/forum/t/text-on-footer-invoices-easily/24983/6 "2024-02-20T06:35:26Z")

</div>

I hope someone else can answer that question, because I can not find it right now ☹

---

<div class="post-metadata">

**Author:** ![gurksallad](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/g/9d8465/32.png) [@gurksallad](https://www.dolibarr.org/forum/u/gurksallad)\
**Post date:** [February 26, 2024, 4:51pm UTC](https://www.dolibarr.org/forum/t/text-on-footer-invoices-easily/24983/7 "2024-02-26T16:51:58Z")

</div>

The code responsible for the footer is in `core/lib/pdf.lib.php`, in function `pdf_pagefoot()`. An easy way to change the footer is to copy one of the existing pdf-modules and change the `function _pagefoot()` in the bottom of the file. There is the call into `pdf_pagefoot()` so it’s easy to overload it that way.

---

<div class="post-metadata">

**Author:** ![EsDeeEm](https://www.dolibarr.org/forum/user_avatar/www.dolibarr.org/esdeeem/32/8224_2.png) [@EsDeeEm](https://www.dolibarr.org/forum/u/EsDeeEm)\
**Post date:** [January 17, 2025, 4:25pm UTC](https://www.dolibarr.org/forum/t/text-on-footer-invoices-easily/24983/8 "2025-01-17T16:25:27Z")

</div>

I added HTML support to the snippet. This way you can have more freedom with the layout, fonts, font color, etc…

```auto
$spaceAvailable = $dims['wk'] - $dims['lm'] - $dims['rm'];

// Path to text file
$filePathRoot = DOL_DOCUMENT_ROOT.'/page_footer.txt';

if (file_exists($filePathRoot)) {
    $persText = file_get_contents($filePathRoot);
    
    // Convert HTML entities
    $persText = html_entity_decode($persText, ENT_QUOTES | ENT_HTML5, 'UTF-8');
} else {
    $persText = "Footer contents not found";
}

// Keep position in line with original code
$pdf->SetXY($dims['lm'], -$posy - getDolGlobalInt('PDF_FOOTER_PAGE_NUMBER_Y', 0));

// Instead of MultiCell using writeHTMLCell for HTML support in TCPDF
if (method_exists($pdf, 'writeHTMLCell')) {
    // set font and fontcolor for HTML content
    $pdf->SetFont($this->fontfamilyname, '', 8); // you can change the font & size here
    $pdf->SetTextColor(82, 74, 112); // your own color of choice
    
    // Rendering HTML content with same dimensions as original
    $pdf->writeHTMLCell($spaceAvailable, 10, $dims['lm'], -$posy - getDolGlobalInt('PDF_FOOTER_PAGE_NUMBER_Y', 0), $persText, 0, 1, 0, true, 'C');
} else {
    // fallback to plain text if HTML is not supported
    $pdf->MultiCell($spaceAvailable, 10, strip_tags($persText), 0, 'C', 0);

```

Have fun 🙂
