Add options in function pdf_pagefoot & pdf_pagehead of pdf.lib.php

This commit is contained in:
root 2023-02-02 17:28:47 +01:00
parent 1be5145148
commit 0950df7b63

View File

@ -724,11 +724,13 @@ function pdf_pagehead(&$pdf, $outputlangs, $page_height)
$filepath = $conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF; $filepath = $conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF;
if (file_exists($filepath)) { if (file_exists($filepath)) {
$pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image
if (getDolGlobalString('MAIN_USE_BACKGROUND_ON_PDF_ALPHA')) { $pdf->SetAlpha($conf->global->MAIN_USE_BACKGROUND_ON_PDF_ALPHA); } // Option for change opacity of background
$pdf->Image($filepath, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_X : 0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y : 0), 0, $page_height); $pdf->Image($filepath, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_X : 0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y : 0), 0, $page_height);
$pdf->SetPageMark(); // This option avoid to have the images missing on some pages if (getDolGlobalString('MAIN_USE_BACKGROUND_ON_PDF_ALPHA')) { $pdf->SetAlpha(1); }
$pdf->SetAutoPageBreak(1, 0); // Restore pagebreak $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak
} }
} }
$pdf->SetPageMark(); // This option avoid to have the images missing on some pages
} }
@ -1246,6 +1248,9 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
$pdf->SetY(-$posy); $pdf->SetY(-$posy);
// Option for hide all footer (page number will no hidden)
if (getDolGlobalInt('PDF_FOOTER_HIDDEN') !== 1) {
// Hide footer line if footer background color is set // Hide footer line if footer background color is set
if (!getDolGlobalString('PDF_FOOTER_BACKGROUND_COLOR')) { if (!getDolGlobalString('PDF_FOOTER_BACKGROUND_COLOR')) {
$pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy); $pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy);
@ -1286,9 +1291,11 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
} }
} }
} }
}
// Show page nb only on iso languages (so default Helvetica font) // Show page nb only on iso languages (so default Helvetica font)
if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') { if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') {
$pdf->SetXY($dims['wk'] - $dims['rm'] - 18, -$posy); // Option for change XY position of the page number
$pdf->SetXY($dims['wk'] - $dims['rm'] - 18 - ( getDolGlobalString('PDF_FOOTER_PAGE_NUMBER_X') ? floatval(getDolGlobalString('PDF_FOOTER_PAGE_NUMBER_X')) : 0 ) , -$posy - ( getDolGlobalString('PDF_FOOTER_PAGE_NUMBER_Y') ? floatval(getDolGlobalString('PDF_FOOTER_PAGE_NUMBER_Y')) : 0 ));
//$pdf->MultiCell(18, 2, $pdf->getPageNumGroupAlias().' / '.$pdf->getPageGroupAlias(), 0, 'R', 0); //$pdf->MultiCell(18, 2, $pdf->getPageNumGroupAlias().' / '.$pdf->getPageGroupAlias(), 0, 'R', 0);
$pdf->MultiCell(18, 2, $pdf->PageNo().' / '.$pdf->getAliasNbPages(), 0, 'R', 0); $pdf->MultiCell(18, 2, $pdf->PageNo().' / '.$pdf->getAliasNbPages(), 0, 'R', 0);
} }