bug fix: tcpdf total page numbers for groups (#2632)

The total page number was not correct for groups. The page number for a non-group was used, which produced the wrong result.
This commit is contained in:
Anthony Andriano
2023-03-04 10:42:58 -07:00
committed by GitHub
parent 2655f0d9c5
commit da5b1cf005

View File

@@ -128,20 +128,7 @@ class Tcpdf extends TcpdfOriginal
$html = $this->headerHtml;
if ($this->useGroupNumbers) {
$html = str_replace('{pageNumber}', '{{:png:}}', $html);
$html = str_replace('{pageAbsoluteNumber}', '{{:pnp:}}', $html);
} else {
$html = str_replace('{pageNumber}', '{{:pnp:}}', $html);
$html = str_replace('{pageAbsoluteNumber}', '{{:pnp:}}', $html);
}
/** @phpstan-ignore-next-line */
if ($this->isUnicodeFont()) {
$html = str_replace('{totalPageNumber}', '{{:ptp:}}', $html);
} else {
$html = str_replace('{totalPageNumber}', '{:ptp:}', $html);
}
$html = $this->setPageNumbers($html);
$this->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, '', 0, false);
}
@@ -160,26 +147,43 @@ class Tcpdf extends TcpdfOriginal
$html = $this->footerHtml;
if ($this->useGroupNumbers) {
$html = str_replace('{pageNumber}', '{{:png:}}', $html);
$html = str_replace('{pageAbsoluteNumber}', '{{:pnp:}}', $html);
} else {
$html = str_replace('{pageNumber}', '{{:pnp:}}', $html);
$html = str_replace('{pageAbsoluteNumber}', '{{:pnp:}}', $html);
}
/** @phpstan-ignore-next-line */
if ($this->isUnicodeFont()) {
$html = str_replace('{totalPageNumber}', '{{:ptp:}}', $html);
} else {
$html = str_replace('{totalPageNumber}', '{:ptp:}', $html);
}
$html = $this->setPageNumbers($html);
$this->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, '', 0, false);
$this->SetAutoPageBreak($autoPageBreak, $breakMargin);
}
/**
* @param string $html
* @return string
*/
private function setPageNumbers($html): string {
if ($this->useGroupNumbers) {
$html = str_replace('{pageNumber}', '{{:png:}}', $html);
$html = str_replace('{pageAbsoluteNumber}', '{{:pnp:}}', $html);
/** @phpstan-ignore-next-line */
if ($this->isUnicodeFont()) {
$html = str_replace('{totalPageNumber}', '{{:ptg:}}', $html);
} else {
$html = str_replace('{totalPageNumber}', '{:ptg:}', $html);
}
} else {
$html = str_replace('{pageNumber}', '{{:pnp:}}', $html);
$html = str_replace('{pageAbsoluteNumber}', '{{:pnp:}}', $html);
/** @phpstan-ignore-next-line */
if ($this->isUnicodeFont()) {
$html = str_replace('{totalPageNumber}', '{{:ptp:}}', $html);
} else {
$html = str_replace('{totalPageNumber}', '{:ptp:}', $html);
}
}
return $html;
}
/**
* @param string $name
* @param string $dest