My Node.js code snippet is as follows:
await page.setContent(html, {waitUntil: 'networkidle2'});
const pdf = await page.pdf({
format: 'A4',
printBackground: true,
margin: {
top: '14mm', // default is 0, units: mm, cm, in, px
right: '10mm',
bottom: '35mm',
left: '12mm'
},
displayHeaderFooter: true,
headerTemplate: header,
footerTemplate: footer
});
I have managed to create an HTML that displays the height correctly in Chrome: https://i.sstatic.net/g8buZ.png
However, when converting this into a pdf
, the TR height is not taken into account (as shown by the red line):
https://i.sstatic.net/WePvF.png
I have tried various methods to adjust the table height and the TR elements to fill the entire page for the PDF output without success...
Update 1:
To visualize how the page appears, I included a screenshot capture with
await page.screenshot({path: '/tmp/full_img.png', fullPage: true});
The resulting image shows this view: https://i.sstatic.net/bbgpp.png
From this, it is evident that the page renders correctly in the "browser" but the "printed" PDF does not.
Update 2:
I also added borders to the page objects, revealing that the body (yellow) and the main container (green), which holds the tables, are displaying correctly while only the table (cyan) is deviating from the design:
https://i.sstatic.net/sa7KX.png
Update 3:
Comparing the "Print" option in Chrome on my local browser to Puppeteer's output, they now align consistently:
https://i.sstatic.net/rkRNB.png
Easier to test of course... Below is the updated HTML link as well: https://github.com/puppeteer/puppeteer/files/5747755/ut.html.txt