Create a PDF document template: Difference between revisions

Update the path to the TCPDF lib.
Tag: 2017 source edit
(Update the path to the TCPDF lib.)
Line 33: Line 33:
For instance, a customized proposal template will be located in '''...core/modules/propale/doc/'''
For instance, a customized proposal template will be located in '''...core/modules/propale/doc/'''


=Create a new template =
=Create a new template=
== For an existing module ==
==For an existing module==
Do not modify an existing template. Copy the file of the template used as example into a new name in same directory than your example and edit it to change content.
Do not modify an existing template. Copy the file of the template used as example into a new name in same directory than your example and edit it to change content.
For this example, we will call our new template 'mycompanyblue', based on the existing template 'azur':
For this example, we will call our new template 'mycompanyblue', based on the existing template 'azur':
Line 50: Line 50:
Add into table '''llx_document_model''' the new document template that you have created.
Add into table '''llx_document_model''' the new document template that you have created.


== For a new module ==
==For a new module==
Just use the [[Module Builder]] from v12.0 to create your module. When entering the name of a new object to create, you can also check a checkbox to say that you want to manage documents for such new object. In such a case, two templates will be automatically generated (one ODT template and one PDF template).
Just use the [[Module Builder]] from v12.0 to create your module. When entering the name of a new object to create, you can also check a checkbox to say that you want to manage documents for such new object. In such a case, two templates will be automatically generated (one ODT template and one PDF template).


The templates will be generated with path:
The templates will be generated with path:
* custom/mymodule/core/modules/doc/pdf_standard_myobject.class.php
 
* custom/mymodule/core/modules/doc/doc_generic_myobject_odt.class.php
*custom/mymodule/core/modules/doc/pdf_standard_myobject.class.php
*custom/mymodule/core/modules/doc/doc_generic_myobject_odt.class.php


=Customize content of your new template=
=Customize content of your new template=
Line 150: Line 151:
This is probably a font problem, the current font used for generating the PDF cannot handle the foreign characters you are trying to print. So just try to use another font.
This is probably a font problem, the current font used for generating the PDF cannot handle the foreign characters you are trying to print. So just try to use another font.


You will find the fonts used by Dolibarr to print PDF inside your Dolibarr folder.../includes/tcpdf/fonts/
You will find the fonts used by Dolibarr to print PDF inside your Dolibarr folder.../includes/tecnickcom/tcpdf/fonts/


To change the font used for generating PDF, you need to edit the 'main.lang' file of the language you are using (you'll find the file in your Dolibarr.../langs/en_US/main.lang for instance if you use English)
To change the font used for generating PDF, you need to edit the 'main.lang' file of the language you are using (you'll find the file in your Dolibarr.../langs/en_US/main.lang for instance if you use English)
Line 158: Line 159:
*Save the file and try again to generate your PDF.
*Save the file and try again to generate your PDF.


If you are unlucky, you can try with more fonts, just go to the TCPDF website sourceforge.net/projects/tcpdf/files/ and download the latest zip package. Then extract only the 'fonts' folder from the zip. Then copy the files in your Dolibarr installation .../includes/tcpdf/fonts/ so you will get more fonts to play with.
If you are unlucky, you can try with more fonts, just go to the TCPDF website sourceforge.net/projects/tcpdf/files/ and download the latest zip package. Then extract only the 'fonts' folder from the zip. Then copy the files in your Dolibarr installation .../includes/tecnickcom/tcpdf/fonts/ so you will get more fonts to play with.


Also, please make a backup of your files modification.
Also, please make a backup of your files modification.
1

edit