1
edit
mNo edit summary Tag: 2017 source edit |
m (path added "htdocs/includes/tecnickcom/tcpdf/tcpdf.class.php" because file was not found under previous shown path. Left old path written, because it was not possible to proove that old path is not correct in older Dolibarr Versions) |
||
| Line 69: | Line 69: | ||
==Library for PDF manipulation== | ==Library for PDF manipulation== | ||
The library used to create PDF documents in PHP is called FPDF and can be found in htdocs/includes/tcpdf/tcpdf.class.php. This class contains the methods used to generate different parts of documents. | The library used to create PDF documents in PHP is called FPDF and can be found in htdocs/includes/tcpdf/tcpdf.class.php (or htdocs/includes/tecnickcom/tcpdf/tcpdf.class.php). This class contains the methods used to generate different parts of documents. | ||
Templates instantiate the FPDF class and use its methods combined with the specific data of the invoice, order etc. | Templates instantiate the FPDF class and use its methods combined with the specific data of the invoice, order etc. | ||
| Line 100: | Line 100: | ||
*Add following instructions | *Add following instructions | ||
< | <syntaxhighlight lang="PHP"> | ||
$pdf->Image('\www\htdocs\dolibarr\document\societe\logo.jpg', 10, 5, 60.00); | $pdf->Image('\www\htdocs\dolibarr\document\societe\logo.jpg', 10, 5, 60.00); | ||
</ | </syntaxhighlight> | ||
With this example: 10=abscissa, 5=ordinate, 60=with of logo | With this example: 10=abscissa, 5=ordinate, 60=with of logo | ||
| Line 109: | Line 109: | ||
===Insert text=== | ===Insert text=== | ||
Most common function to use | Most common function to use | ||
< | <syntaxhighlight lang="PHP"> | ||
$pdf->setX(float a); // set current x position | $pdf->setX(float a); // set current x position | ||
$pdf->setY(float b); // set current y position | $pdf->setY(float b); // set current y position | ||
| Line 116: | Line 116: | ||
$pdf->SetFont('Arial','B',14); // fixe la police, le type ( 'B' pour gras, 'I' pour italique, '' pour normal,...) | $pdf->SetFont('Arial','B',14); // fixe la police, le type ( 'B' pour gras, 'I' pour italique, '' pour normal,...) | ||
$pdf->MultiCell(60, 8, 'Mon texte", 0, 'L'); // imprime 'Mon texte' avec saut de ligne | $pdf->MultiCell(60, 8, 'Mon texte", 0, 'L'); // imprime 'Mon texte' avec saut de ligne | ||
</ | </syntaxhighlight> | ||
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)=== | ===Add a PDF Annotation (comment)=== | ||
''Left side of the page around the middle:'' | ''Left side of the page around the middle:'' | ||
< | <syntaxhighlight 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))); | $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))); | ||
</ | </syntaxhighlight> | ||
''Right side of the page around the middle:'' | ''Right side of the page around the middle:'' | ||
< | <syntaxhighlight 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))); | $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))); | ||
</ | </syntaxhighlight> | ||
===Add Complementary Attribute (extrafiled)=== | ===Add Complementary Attribute (extrafiled)=== | ||
edit