PDF Custom Invoice

Hello,

My small contribution of creation on the custom invoices.

I Use the Dolibarr ODT Template resource (Create an ODT document template - Dolibarr ERP CRM Wiki) with jodconverter (odt to pdf converter).

Steps:

  1. Create your ODT Template in OpenOffice or LibreOffice. eg: www.comdesk.com.br/downloads/template_invoice.odt

  2. Replace the original ODT Template. The path is: \documents\doctemplates\invoices.

  3. Edit the file: doc_generic_invoice_odt.modules. The path is: \htdocs\core\modules\facture\doc\

  4. Around line 315, add the code:

//Variable for convert odt to pdf - Marcelo Costa $filePDF='jodconverter -f pdf '.$file;

  1. Around line 502, add the code:

//Execute jodconverter - Marcelo Costa exec($filePDF); //Delete odt reference - Marcelo Costa unlink($file);

  1. In your LAMP server, install the jodconverter. apt-get install jodconverter.

  2. Create a script to start openoffice service on the linux.

- Create the new file:

- Input the content in this file:

- Give permission to execute:

- Start with a your system:

  1. Restart the server.

  2. In Dolibarr, enable the ODT templates, in Invoice Modules.

  3. When generate a invoice, choose the model template_invoice.odt.

The routine with tested in Ubuntu Server 10.04…Another server, see jodconverter documentation.

Regards,
Marcelo

For which version is this?

@marceloeng: Thank’s for the tutorial, nice feedback.

IT-KAM wrote:

This should work for any Dolibarr version that supports the ODT templating system, so Dolibarr >= 3.2

Hi,

I believe that work in 3.2 version or high.

I have tested with 3.3.0 Alpha. Last trunk downloaded in github on 25 ocotber.

Regards,
Marcelo

Thanks for the quick response! I am right now on 3.2.2 so I will give it a try on my test machine.

Hi marcelo, thanks for you usefull suggestion!
A question: i use dolibarr on windows, i need to install jodconverter and the Openoffice’s script also on windows?
Can you help me make it working also on windows?
Thanks in advance

Hi godevolution,

I have not testet, but I believe that you shoul install jodconverter (http://sourceforge.net/projects/jodconverter/files/JODConverter/2.2.2/) and create openffice service (http://www.artofsolving.com/node/11).


Marcelo

Thanks Marcelo,

Great solution, I have this working on 3.2.2. Couple of notes.

  1. I ran as follows to install openoffice on 10.04

apt-get install openoffice.org-headless openoffice.org-writer openoffice.org-draw

then installed jod converter.

  1. The code at line 502 needs to be before line
    “return 1; // Success”

This is great Marcelo !

Thank you for sharing.

In my case, i have installed dolibarr in my hosting, so i don have access to linux for do that.

Do you think is it possible that Dolibarr creates a PDF from my modified ODT only using PHP?, if yes, it will make me very happy :woohoo:

toomanylogins,

When install JOD Converter (apt-get install jodconverter), your dependecies are installed also.

Yes…the code need before “return 1; // Success”.

Planpc,
Is possible, but very hard.
see the link: http://wiki.dolibarr.org/index.php/Create_a_PDF_document_template

Ok Marcelo than you for the link,

i visit that link before made this question, but it is for creatin a PDF template using PHP, I´m not a programmer, so it is not for me :unhappy:

I´m looking for somethin really simple for me or other users.

Sorry if my question was not correctry made, what i will like to do is that Dolibarr could print in a PDF, my ready modified template ODT, if is possible.

Imagine the one you share in the first post (http://www.comdesk.com.br/downloads/template_invoice.odt) or some other similar, that anybody could modify, text, color, etc., without knowing PHP and make the default template. It will be perfect, and much more easier to customice than any desktop application here, in Spain.

I´ve been searching in internet, and maybe on way could be, transform ODT in an HTML, an the in a PDF, http://www.phpclasses.org/browse/file/10912.html

Thank you for your interest anyway

Hi planpc,

This is a great idea and is possible create a routine for this, but the odt2html converter php script have dificulties with tables.

In this moment I don’t have time for research, but in next month I make a few tests.

Regards,
Marcelo

Thank you again Marcelo,

you words are music for my ears ! :woohoo:

I will wait, if you think i could help you in any way, just tell me.

Regards

@Marcelo: Do you know, how this could work for windows?

planpc wrote:

Indeed this kind of ODT->PDF transformation only works by calling a binary, so this doesn’t work on shared hosts (most websites hosts in fact).

I have already searched on the subject (how to transform ODT to PDF only by using PHP), but there is no quick solution as of today.

But there are a few new libraries which can give us hope, but then you would need to rewrite a whole library interface for Dolibarr (because these libraries can’t know where are the variables to change, the current ODT generator works in a similar way as an interface between Dolibarr and the odtphp library).

You can find a summary of what I found here:
www.dolibarr.org/t/an-easy-way-to-modify-pdf-templates/8775/1

Anyway, don’t expect this solution to be released soon (if ever): it would be a lot of work for very little advantage (because you can just make a PDF template using PHP, or convert your ODT document by yourself on your computer, Microsoft Office and LibreOffice both offer this functionality natively).

/EDIT: I think I have found a solution. I will keep you guys updated on this when I’ll work on it in June.

I want to change the name of the pdf template example from “invoice” to “proforma invoice”. Can you help me with how to do that. Thank you