158 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
161 global $user, $langs,
$conf, $mysoc, $db, $hookmanager, $nblines;
163 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
165 if (!is_object($outputlangs)) {
166 $outputlangs = $langs;
170 $outputlangs->charset_output =
'ISO-8859-1';
174 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
176 global $outputlangsbis;
177 $outputlangsbis =
null;
181 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies"));
184 $nblines = (is_array(
$object->lines) ? count(
$object->lines) : 0);
191 if (
$conf->asset->dir_output.
'/asset') {
196 $dir =
$conf->asset->dir_output.
'/asset';
197 $file = $dir.
"/SPECIMEN.pdf";
200 $dir =
$conf->asset->dir_output.
'/asset/'.$objectref;
201 $file = $dir.
"/".$objectref.
".pdf";
203 if (!file_exists($dir)) {
205 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
210 if (file_exists($dir)) {
212 if (!is_object($hookmanager)) {
213 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
216 $hookmanager->initHooks(array(
'pdfgeneration'));
217 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
219 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
222 $nblines = (is_array(
$object->lines) ? count(
$object->lines) : 0);
227 $pdf->SetAutoPageBreak(1, 0);
229 $heightforinfotot = 50;
231 $heightforfooter = $this->marge_basse + (!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22);
233 if (class_exists(
'TCPDF')) {
234 $pdf->setPrintHeader(
false);
235 $pdf->setPrintFooter(
false);
241 $logodir =
$conf->mycompany->dir_output;
242 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
243 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
245 $pagecount = $pdf->setSourceFile($logodir .
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
246 $tplidx = $pdf->importPage(1);
251 $pdf->SetDrawColor(128, 128, 128);
253 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
254 $pdf->SetSubject($outputlangs->transnoentities(
"PdfTitle"));
255 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
256 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
257 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
259 $pdf->SetCompression(
false);
263 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
271 'Name' => $this->emetteur->name,
272 'Location' =>
getCountry($this->emetteur->country_code,
''),
274 'ContactInfo' => $this->emetteur->email
276 $pdf->setSignature($cert, $cert, $this->emetteur->name,
'', 2, $info);
280 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
284 if (!empty($tplidx)) {
285 $pdf->useTemplate($tplidx);
289 $top_shift = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
290 $pdf->SetFont(
'',
'', $default_font_size - 1);
291 $pdf->MultiCell(0, 3,
'');
292 $pdf->SetTextColor(0, 0, 0);
294 $tab_top = 90 + $top_shift;
295 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
296 $tab_height = 130 - $top_shift;
297 $tab_height_newpage = 150;
299 $tab_height_newpage -= $top_shift;
302 $nexY = $tab_top - 1;
305 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
307 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
308 if (!empty($extranote)) {
312 $pagenb = $pdf->getPage();
316 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
317 $pageposbeforenote = $pagenb;
324 $pdf->startTransaction();
326 $pdf->SetFont(
'',
'', $default_font_size - 1);
327 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
329 $pageposafternote = $pdf->getPage();
330 $posyafter = $pdf->GetY();
332 if ($pageposafternote > $pageposbeforenote) {
333 $pdf->rollbackTransaction(
true);
336 while ($pagenb < $pageposafternote) {
339 if (!empty($tplidx)) {
340 $pdf->useTemplate($tplidx);
346 $pdf->setTopMargin($tab_top_newpage);
348 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
352 $pdf->setPage($pageposbeforenote);
353 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
354 $pdf->SetFont(
'',
'', $default_font_size - 1);
355 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
356 $pageposafternote = $pdf->getPage();
358 $posyafter = $pdf->GetY();
360 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
361 $pdf->AddPage(
'',
'',
true);
364 $pdf->setPage($pageposafternote);
365 $pdf->setTopMargin($tab_top_newpage);
367 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
373 $i = $pageposbeforenote;
374 while ($i < $pageposafternote) {
378 $pdf->SetDrawColor(128, 128, 128);
380 if ($i > $pageposbeforenote) {
381 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
382 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
384 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
385 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
389 $pdf->setPageOrientation(
'', 1, 0);
396 $pdf->setPage($pageposafternote);
397 if (!empty($tplidx)) {
398 $pdf->useTemplate($tplidx);
403 $height_note = $posyafter - $tab_top_newpage;
404 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
406 $pdf->commitTransaction();
407 $posyafter = $pdf->GetY();
408 $height_note = $posyafter - $tab_top;
409 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
412 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
414 $pdf->AddPage(
'',
'',
true);
417 $pdf->setPage($pageposafternote);
418 if (!empty($tplidx)) {
419 $pdf->useTemplate($tplidx);
425 $posyafter = $tab_top_newpage;
429 $tab_height -= $height_note;
430 $tab_top = $posyafter + 6;
439 $pdf->startTransaction();
440 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
441 $pdf->rollbackTransaction(
true);
443 $nexY = $tab_top + $this->tabTitleHeight;
446 $pageposbeforeprintlines = $pdf->getPage();
447 $pagenb = $pageposbeforeprintlines;
448 for ($i = 0; $i < $nblines; $i++) {
450 $pdf->SetFont(
'',
'', $default_font_size - 1);
451 $pdf->SetTextColor(0, 0, 0);
453 $pdf->setTopMargin($tab_top_newpage);
454 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
455 $pageposbefore = $pdf->getPage();
457 $showpricebeforepagebreak = 1;
462 $pdf->startTransaction();
465 $pageposafter = $pdf->getPage();
467 if ($pageposafter > $pageposbefore) {
468 $pdf->rollbackTransaction(
true);
469 $pdf->setPageOrientation(
'', 1, $heightforfooter);
473 $pageposafter = $pdf->getPage();
474 $posyafter = $pdf->GetY();
476 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
477 if ($i == ($nblines - 1)) {
478 $pdf->AddPage(
'',
'',
true);
479 if (!empty($tplidx)) {
480 $pdf->useTemplate($tplidx);
482 $pdf->setPage($pageposafter + 1);
488 $showpricebeforepagebreak = 1;
490 $showpricebeforepagebreak = 0;
494 $pdf->commitTransaction();
498 $nexY = $pdf->GetY();
499 $pageposafter = $pdf->getPage();
500 $pdf->setPage($pageposbefore);
501 $pdf->setTopMargin($this->marge_haute);
502 $pdf->setPageOrientation(
'', 1, 0);
505 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
506 $pdf->setPage($pageposafter);
507 $curY = $tab_top_newpage;
510 $pdf->SetFont(
'',
'', $default_font_size - 1);
517 $nexY = max($pdf->GetY(), $nexY);
521 if (!empty(
$object->lines[$i]->array_options)) {
522 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
526 $nexY = max($pdf->GetY(), $nexY);
538 'outputlangs' => $outputlangs,
539 'hidedetails' => $hidedetails
541 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
546 $prev_progress =
$object->lines[$i]->get_prev_progress(
$object->id);
547 if ($prev_progress > 0 && !empty(
$object->lines[$i]->situation_percent)) {
548 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
549 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
551 $tvaligne = $sign *
$object->lines[$i]->total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
554 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
555 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva;
557 $tvaligne = $sign *
$object->lines[$i]->total_tva;
561 $localtax1ligne =
$object->lines[$i]->total_localtax1;
562 $localtax2ligne =
$object->lines[$i]->total_localtax2;
563 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
564 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
565 $localtax1_type =
$object->lines[$i]->localtax1_type;
566 $localtax2_type =
$object->lines[$i]->localtax2_type;
579 $vatrate = (string)
$object->lines[$i]->tva_tx;
582 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
583 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
585 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
586 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
590 if ($localtax1_type && $localtax1ligne != 0) {
591 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
592 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
594 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
597 if ($localtax2_type && $localtax2ligne != 0) {
598 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
599 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
601 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
605 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
608 if (!isset($this->tva[$vatrate])) {
609 $this->tva[$vatrate] = 0;
611 $this->tva[$vatrate] += $tvaligne;
613 $nexY = max($nexY, $posYAfterImage);
617 $pdf->setPage($pageposafter);
618 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
620 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
621 $pdf->SetLineStyle(array(
'dash' => 0));
625 while ($pagenb < $pageposafter) {
626 $pdf->setPage($pagenb);
627 if ($pagenb == $pageposbeforeprintlines) {
628 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
630 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code, $outputlangsbis);
634 $pdf->setPage($pagenb);
635 $pdf->setPageOrientation(
'', 1, 0);
641 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
642 if ($pagenb == $pageposafter) {
643 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code, $outputlangsbis);
645 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code, $outputlangsbis);
650 if (!empty($tplidx)) {
651 $pdf->useTemplate($tplidx);
661 if ($pagenb == $pageposbeforeprintlines) {
662 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code, $outputlangsbis);
663 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
665 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code, $outputlangsbis);
666 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
685 if (method_exists($pdf,
'AliasNbPages')) {
686 $pdf->AliasNbPages();
691 $pdf->Output($file,
'F');
694 $hookmanager->initHooks(array(
'pdfgeneration'));
695 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
697 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
699 $this->error = $hookmanager->error;
700 $this->errors = $hookmanager->errors;
705 $this->result = array(
'fullpath' => $file);
709 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
713 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"ASSET_OUTPUTDIR");
804 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
806 global
$conf, $langs;
809 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
817 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm',
$conf->global->FACTURE_DRAFT_WATERMARK);
820 $pdf->SetTextColor(0, 0, 60);
821 $pdf->SetFont(
'',
'B', $default_font_size + 3);
825 $posy = $this->marge_haute;
826 $posx = $this->page_largeur - $this->marge_droite - $w;
828 $pdf->SetXY($this->marge_gauche, $posy);
832 if ($this->emetteur->logo) {
833 $logodir =
$conf->mycompany->dir_output;
834 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
835 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
838 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
840 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
842 if (is_readable($logo)) {
844 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
846 $pdf->SetTextColor(200, 0, 0);
847 $pdf->SetFont(
'',
'B', $default_font_size - 2);
848 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
849 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
852 $text = $this->emetteur->name;
853 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
857 $pdf->SetFont(
'',
'B', $default_font_size + 3);
858 $pdf->SetXY($posx, $posy);
859 $pdf->SetTextColor(0, 0, 60);
860 $title = $outputlangs->transnoentities(
"PdfTitle");
863 $title .= $outputlangsbis->transnoentities(
"PdfTitle");
865 $pdf->MultiCell($w, 3, $title,
'',
'R');
867 $pdf->SetFont(
'',
'B', $default_font_size);
870 $pdf->SetXY($posx, $posy);
871 $pdf->SetTextColor(0, 0, 60);
872 $textref = $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset(
$object->ref);
873 if (
$object->status == $object::STATUS_DRAFT) {
874 $pdf->SetTextColor(128, 0, 0);
875 $textref .=
' - '.$outputlangs->transnoentities(
"NotValidated");
877 $pdf->MultiCell($w, 4, $textref,
'',
'R');
880 $pdf->SetFont(
'',
'', $default_font_size - 2);
891 if (!empty(
$object->project->ref)) {
893 $pdf->SetXY($posx, $posy);
894 $pdf->SetTextColor(0, 0, 60);
895 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->projet->title),
'',
'R');
901 if (!empty(
$object->project->ref)) {
902 $outputlangs->load(
"projects");
904 $pdf->SetXY($posx, $posy);
905 $pdf->SetTextColor(0, 0, 60);
906 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
911 $pdf->SetXY($posx, $posy);
912 $pdf->SetTextColor(0, 0, 60);
914 $title = $outputlangs->transnoentities(
"Date");
916 $title .=
' - '.$outputlangsbis->transnoentities(
"Date");
918 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_acquisition,
"day",
false, $outputlangs),
'',
'R');
920 if (
$object->thirdparty->code_client) {
922 $pdf->SetXY($posx, $posy);
923 $pdf->SetTextColor(0, 0, 60);
924 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
929 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
930 if (count($arrayidcontact) > 0) {
931 $usertmp =
new User($this->db);
932 $usertmp->fetch($arrayidcontact[0]);
934 $pdf->SetXY($posx, $posy);
935 $pdf->SetTextColor(0, 0, 60);
936 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
944 $current_y = $pdf->getY();
946 if ($current_y < $pdf->getY()) {
947 $top_shift = $pdf->getY() - $current_y;
957 $posx = $this->marge_gauche;
959 $posx = $this->page_largeur - $this->marge_droite - 80;
967 $pdf->SetTextColor(0, 0, 0);
968 $pdf->SetFont(
'',
'', $default_font_size - 2);
969 $pdf->SetXY($posx, $posy - 5);
970 $pdf->MultiCell(66, 5, $outputlangs->transnoentities(
"BillFrom").
":", 0,
'L');
971 $pdf->SetXY($posx, $posy);
972 $pdf->SetFillColor(230, 230, 230);
973 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
974 $pdf->SetTextColor(0, 0, 60);
977 $pdf->SetXY($posx + 2, $posy + 3);
978 $pdf->SetFont(
'',
'B', $default_font_size);
979 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
980 $posy = $pdf->getY();
983 $pdf->SetXY($posx + 2, $posy);
984 $pdf->SetFont(
'',
'', $default_font_size - 1);
985 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
989 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
990 if (count($arrayidcontact) > 0) {
992 $result =
$object->fetch_contact($arrayidcontact[0]);
997 $thirdparty =
$object->contact;
999 $thirdparty =
$object->thirdparty;
1002 if (is_object($thirdparty)) {
1010 if ($this->page_largeur < 210) {
1014 $posy += $top_shift;
1015 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1017 $posx = $this->marge_gauche;
1021 $pdf->SetTextColor(0, 0, 0);
1022 $pdf->SetFont(
'',
'', $default_font_size - 2);
1023 $pdf->SetXY($posx + 2, $posy - 5);
1024 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo").
":", 0,
'L');
1025 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1028 $pdf->SetXY($posx + 2, $posy + 3);
1029 $pdf->SetFont(
'',
'B', $default_font_size);
1030 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1032 $posy = $pdf->getY();
1035 $pdf->SetFont(
'',
'', $default_font_size - 1);
1036 $pdf->SetXY($posx + 2, $posy);
1037 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1040 $pdf->SetTextColor(0, 0, 0);