'Generating a PDF from HTML using Puppeteer duplicates content
I've noticed when generating a PDF from HTML using puppeteer, it's sometimes duplicating the bottom content on the next page..
e.g. you can see here the table header is repeated on the next page. I've checked the HTML, and it definitely doesn't repeat.
Any idea why it's doing that?
My code looks like this..
const htmlToPdf = async html => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
// https://pptr.dev/#?product=Puppeteer&version=v13.6.0&show=api-pagesetcontenthtml-options
await page.setContent(html);
// https://pptr.dev/#?product=Puppeteer&version=v13.6.0&show=api-pagepdfoptions
const buffer = await page.pdf({
format: 'A4',
printBackground: true
});
await browser.close();
return buffer;
};
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|