Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Support
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
pagedjs
pagedjs
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 144
    • Issues 144
    • List
    • Boards
    • Labels
    • Milestones
  • Merge Requests 8
    • Merge Requests 8
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Tools
  • pagedjspagedjs
  • Issues
  • #198

Closed
Open
Opened Apr 20, 2020 by Juul@Juul
  • Report abuse
  • New issue
Report abuse New issue

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.

image

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?

Edited Apr 22, 2020 by Juul
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
0
Labels
None
Assign labels
  • View project labels
Reference: tools/pagedjs#198