mccarlosen / laravel-mpdf

Generate PDFs in Laravel with Mpdf.
389 stars 106 forks source link

Footer working only in last page #109

Closed GGarnize closed 1 year ago

GGarnize commented 1 year ago

$footer = '<span>Página {PAGENO} de {nbpg}</span>' $mpdf = PDF::chunkLoadView('<html-separator/>', 'pdf.bladepdf', $data); $mpdf->getMpdf()->SetHTMLFooter($footer);

<style> @page { footer: page-footer; } </style> `

Página {PAGENO} de {nbpg}

`

When Pdf generate 2 or more pages, It works, but when it have just one page, SetHTMLFooter Not cover the footer in blade

mccarlosen commented 1 year ago

If you use the <htmlpagefooter /> tag, it is no longer necessary to use the SetHTMLFooter method.


<style>
    @page {
      footer: page-footer;
    }
</style>

<htmlpagefooter name="page-footer">
    Your Footer Content
</htmlpagefooter>

<h1>Hello World!</h1>
GGarnize commented 1 year ago

I'm trying set custom footer just to last page, and when document have 2 or more pages, my code works, but when this have unique page, my SetHTMLFooter not overwrite the tag <htmlpagefooter />, the function just overwrite when have more pages, then the function change the footer of last page.