Complimentary attributes in Invoice pdf

- Version: [5.06]
- Operating System: [Cent OS 7]
- Web Server: [Apache]
- PHP: [7.0.32]
- Database: [MySQL 10.2]
-URL: core/modules/facture/doc/pdf_crabe.modules.php

I wanted to know how I can insert complimentary attributes to the invoice pdf - pdf_crabe.modules.php
I have gone through the wiki at: and also the forum post:
but still I cannot understand how to get complimentary attributes into pdf_crabe. Kindly assist on what I should insert where.

Can anybody kindly assist on this


What did you not understand exactly?

Ok referring to:
I have understood the first part:

require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';

The second part I do not understand:
Where do I place the below in pdf_crabe?

$extrafields = new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
Load extrafield into object
Extrafields are loaded in $object->array_options array

$object->fetch($rowid); $object->fetch_optionals($rowid,$extralabels);
This code must be placed just after the above.

Display extrafield value of lines into PDF or HTML

After load extrafields

HTML Example

print $object->lines[$i]->array_options[‘options_XXX’];

Where XXX is the code of the extrafields

PDF example

$pdf->MultiCell (0,5, $outputlangs->convToOutputCharset($object->lines[$i]->array_options[‘options_XXX’]),0,‘L’);

Where XXX is the code of the extrafields

What I want to achieve is the following:
I have a complimentary attribute called user in invoice. I would like it to be placed like this:

How do I go about doing this?

Anywhere in the function write_file

If you want to add that texte at that position on the bottom part, this part is manage by the function _tableau_versements
You need to analyse the code to place the above.

I got a better solution to this. Under Invoice Module setup there are substitution variables:

So what I did in free text was type in Prepared by: then the subs variable USER_FULLNAME This prints the user who prepares or rather generates the pdf invoice.
This was not there in versions 5.x it was introduced in v6.
At least problem solved. But I still need step by step help on extra fields insertion just by merely saying I need to look at this element still does not help me I need step by step on what to do, what to insert where.


Good that you found a solution !

For extrfield there is a step by step here :
DOwnload the pdf, it is in french but easy to understand I think.

1 Like

Thanks ksar. I can get Google to translate the pdf.

This file link is no more working any hel pleas


Everything is on the wiki : Add Extrafields on PDF Models - Dolibarr ERP CRM Wiki