Reputation: 555
Using Laravel Framework 10.48.3
I'm using the following in my scripts tag:
<script type="text/php">
if (isset($pdf)) {
$text = "page {PAGE_NUM} / {PAGE_COUNT}";
$size = 10;
$font = $fontMetrics->getFont("Verdana");
$width = $fontMetrics->get_text_width($text, $font, $size) / 2;
$x = ($pdf->get_width() - $width) / 2;
$y = $pdf->get_height() - 35;
$pdf->page_text($x, $y, $text, $font, $size);
}
</script>
Usage in Controller:
public function getOutput(): string
{
$pdf = PDF::loadView($this->getOutputBladeTemplate(), $this->getOutputData());
return $pdf->output();
}
Below is a screenshot of Page 1, there are 2 pages in this document and the total count appears to have a 1 and 2 overlap
On the second page however it appears correctly:
In styling I'm currently using:
<style>
header {
position: fixed;
}
</style>
If I remove the fixed position then despite having 2 pages only the first page will show: image
and then the second will show no page numbering.
Upvotes: 0
Views: 183
Reputation: 180
Move the script tag to the very end of the document and place it outside of a fixed element. They changed the way the script tag is rendered, see https://github.com/dompdf/dompdf/issues/3279#issuecomment-1725513619
Upvotes: 0
Reputation: 555
Fixed: <main>
tag needed to be above <header>
tag where this was implemented
Upvotes: 0