Create a PDF document template: Difference between revisions

Jump to navigation Jump to search
Add pdf annotation example
(Additional information about customized template location)
(Add pdf annotation example)
Line 9: Line 9:
* Dolibarr: 3.0+
* Dolibarr: 3.0+
* Knowledge in PHP development
* Knowledge in PHP development


= Find a model near your need =
= Find a model near your need =
Line 15: Line 16:
FYI, all models are in '''htdocs/core/modules''', into subdirectory propale for commercial proposals, facture for invoices, commandes for orders, etc... and finally '''doc'''.
FYI, all models are in '''htdocs/core/modules''', into subdirectory propale for commercial proposals, facture for invoices, commandes for orders, etc... and finally '''doc'''.
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 your new template =
= Create your new template =
Line 26: Line 28:
# Save file. Now template is available in the list of models into Dolibarr
# Save file. Now template is available in the list of models into Dolibarr
# Test this model (see previous section) before going further ...
# Test this model (see previous section) before going further ...


= Customize content of your new template =
= Customize content of your new template =
Customize the template created. Still in file pdf_propale_mycompanyblue.modules.php, search function 'Function _pagehead (&$pdf, $fac)'. It manages the display of the header.
Customize the template created. Still in file pdf_propale_mycompanyblue.modules.php, search function 'Function _pagehead (&$pdf, $fac)'. It manages the display of the header.


== Library for PDF manipulation ==
== Library for PDF manipulation ==
Line 42: Line 46:
* $pdf->SetDrawColor() - ''Set the color to use for new text to write - ie black (0,0,0) or white (255,255,255)''
* $pdf->SetDrawColor() - ''Set the color to use for new text to write - ie black (0,0,0) or white (255,255,255)''
* $pdf->Rect() - ''Drwa a rectanle whose top left corner coordinates ared defineds by two first parameters and bottom right corner is defined by two following parameters that are relative values''
* $pdf->Rect() - ''Drwa a rectanle whose top left corner coordinates ared defineds by two first parameters and bottom right corner is defined by two following parameters that are relative values''


== Frame of scripts ==
== Frame of scripts ==
Line 53: Line 58:
* _tableau_versement() - ''Method for drawing table of payment rules''
* _tableau_versement() - ''Method for drawing table of payment rules''
* _pagefoot() - ''Method for drawing bottom of the page''
* _pagefoot() - ''Method for drawing bottom of the page''


== Examples of customization ==
== Examples of customization ==
Line 74: Line 80:
</source>
</source>
Note: Origin for setXY functions are the top left corner of page.
Note: Origin for setXY functions are the top left corner of page.
=== Add a PDF Annotation (comment) ===
''Left side of the page around the middle:''
<source lang="php">
$pdf->Annotation(102, 202, 10, 10, "this is the comment text", array('Subtype'=>'Text', 'Name' => 'Comment', 'T' => 'this is comment author', 'Subj' => 'this is comment title', 'C' => array(255, 255, 0)));
</source>
''Right side of the page around the middle:''
<source lang="php">
$pdf->Annotation(202, 102, 10, 10, "this is the comment text", array('Subtype'=>'Text', 'Name' => 'Comment', 'T' => 'this is comment author', 'Subj' => 'this is comment title', 'C' => array(255, 255, 0)));
</source>


== More information ==
== More information ==
* http://www.fpdf.org/?lang=en
* http://www.fpdf.org/?lang=en
* List of TCPDF's methods: tcpdf.org/doc/code/classTCPDF.html
* List of TCPDF's methods: tcpdf.org/doc/code/classTCPDF.html


= Activate your new model =
= Activate your new model =
Line 83: Line 101:
* activate your module
* activate your module
* eventually, set it as the default model.
* eventually, set it as the default model.


= Troubleshooting =
= Troubleshooting =
75

edits

Navigation menu