I am using the native header and footer functionality of chrome-pdf recipe. I tried to create a pdf of size 24.13cm x 13.97cm and noticed that the footer is missing. I reverted back to A4 and the footer is back again. After some tinkering, I noticed that the footer only appears when height is set to 14.6cm or more.
Here is the link to the playground
To reproduce the missing footer problem, simply change the pdf height value in the playground to 14.5cm .
Here is the list of what I have tried so far but doesn't work:
- Changing the PDF width to 30cm, 24.13cm, and 15cm
- Setting landscape to true/false
- Setting the pdf bottom margin to 3cm, 1cm, and 0.5cm
UPDATE: I tried to generate pdf using puppeteer directly and the footer appears when using my intended pdf height of 13.97cm. It uses puppeteer v21.10.0. Here is the nodejs code.
const chromeOptions = {
displayHeaderFooter: true,
headerTemplate: header,
footerTemplate: footer,
width: '24.13cm',
height: '13.97cm',
margin: {
top: '3cm',
bottom: '1.5cm',
left: '0.5cm',
right: '0.5cm',
},
};
const browser = await puppeteer.launch({ headless: 'new' });
const tab = await browser.newPage();
await tab.setContent(template);
const buff = await tab.pdf(chromeOptions);
await writeFile('./inv.pdf', buff);