Skip to content

Commit

Permalink
FIX incorrect page numbering in PDF #29458 (#29476)
Browse files Browse the repository at this point in the history
* FIX incorrect page numbering in PDF #29458

* Work on width correction

* Work on width correction

* Work on width correction

* Work on code order
  • Loading branch information
fappels committed Apr 27, 2024
1 parent 078c1dd commit fdc1cdd
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions htdocs/core/lib/pdf.lib.php
Expand Up @@ -1303,17 +1303,15 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
}
}
}
// Show page nb only on iso languages (so default Helvetica font)
$pdf->SetXY($dims['wk'] - $dims['rm'] - 18 - getDolGlobalInt('PDF_FOOTER_PAGE_NUMBER_X', 0), -$posy - getDolGlobalInt('PDF_FOOTER_PAGE_NUMBER_Y', 0));

if (getDolGlobalString('PDF_USE_GETALIASNBPAGE_FOR_TOTAL')) {
// $pagination = $pdf->getAliasNumPage().' / '.$pdf->getAliasNbPages(); // works with $pdf->Cell
$pagination = $pdf->PageNo().' / '.$pdf->getAliasNbPages(); // seems to not works with all fonts like ru_UK
} else {
$pagination = $pdf->PageNo().' / '.$pdf->getNumPages(); // seems to always work even with $pdf->Cell. But some users has reported wrong nb (no way to reproduce)
// Show page nb and apply correction for some font.
$pdf->SetXY($dims['wk'] - $dims['rm'] - 18 - getDolGlobalInt('PDF_FOOTER_PAGE_NUMBER_X', 0), -$posy - getDolGlobalInt('PDF_FOOTER_PAGE_NUMBER_Y', 0));
$pagination = $pdf->PageNo().' / '.$pdf->getAliasNbPages();
$fontRenderCorrection = 0;
if (in_array(pdf_getPDFFont($outputlangs), array('freemono', 'DejaVuSans'))) {
$fontRenderCorrection = 10;
}

$pdf->MultiCell(18, 2, $pagination, 0, 'R', 0);
$pdf->MultiCell(18 + $fontRenderCorrection, 2, $pagination, 0, 'R', 0);

// Show Draft Watermark
if (!empty($watermark)) {
Expand Down

0 comments on commit fdc1cdd

Please sign in to comment.