barryvdh / laravel-dompdf

A DOMPDF Wrapper for Laravel
MIT License
6.7k stars 966 forks source link

Page number text overlapping #1055

Closed chdonncha closed 3 months ago

chdonncha commented 3 months ago

Using Laravel Framework 10.48.3

Currently experiencing an issue in regards to the Page numbering. Using the code mentioned in the issue: https://github.com/barryvdh/laravel-dompdf/issues/452

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>

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

image

On the second page however it appears correctly:

image

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.

chdonncha commented 3 months ago

Fixed: <main> tag needed to be above <header> tag where this was implemented