hey try using puppeteer’s displayheaderfooter option with custom footerTemplate rather than css fixed elements. it worked better for dynamic footers on last page; fixed pos can sometimes be skpped in pdf exports.
In my experience with Puppeteer PDF generation, I found that a more robust method than simply relying on fixed CSS positioning is to adjust the page layout entirely through print-specific CSS. I set up a media query for print that reserves enough space at the bottom of each page by adding a bottom margin equivalent to the footer height. The footer is then positioned absolutely within this reserved space on the final page. While this method requires precise measurements and thorough testing, it ensures that the footer remains anchored regardless of how the content is split across pages. This approach has worked for me in multiple projects where consistent footer placement was crucial.
In dealing with Puppeteer PDF issues, I chose to rely on Puppeteer’s built-in header and footer templating options over a fixed CSS positioning approach. I experimented with custom footer templates which offer the flexibility to include dynamic content. This method also allows setting the footer to appear only on the final page by applying conditional logic within the template. It took some trial and error to manage the layout properly, yet it yielded much more consistent results than manipulating the DOM with fixed elements and manual CSS adjustments.
hey, i found that tweaking puppeteer’s pdf() margins to add extra space at the bottom forces the footer on the last page. it took a bit trial n error, but realls did the trick.