Puppeteer output contains only one page & total pages counter shows 0
I've encountered an issue while working on converting HTML print documents to PDF. For this I use Puppeteer 2.1.1
together with the Paged.js polyfill hosted on unpkg.
In the browser documents show up perfectly, showing the total page count and all the pages. But as soon as I use Puppeteer (and also headless Chrome) the output only contains one page and the total pages counter shows 0. When I remove the Paged.js polyfill the output contains all pages.
This occurs with both my own files and the refs-specifications counter-pages.html file.
The output from the the refs-specifications counter-pages file: counter-pages-output.pdf
This is the Puppeteer setup I used to generate the PDF but just using Puppeteer's PDF function should be enough to reproduce this.
(async() => {
try {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(options.input);
await page.emulateMediaType("print");
await page.pdf({
path: `${options.output}`,
preferCSSPageSize: true,
});
await browser.close();
} catch (err) {
console.error("An error occurred while generating output: ", err);
}
})().catch(console.error);
Am I using Puppeteer in the wrong way for files using the Paged.js polyfill or is this a bug?