puppeteer: Print to PDF call not working as expected in example?

In the example:

await page.goto('https://news.ycombinator.com', {waitUntil: 'networkidle'});
await page.pdf({path: 'hn.pdf', format: 'A4'});

This output is generated (for me at least)

hn.pdf

But below is what I get if I manually print from a Chrome browser on the same page.

FromChrome.pdf

Some other sites work as expected, maybe an issue with HN?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (7 by maintainers)

Commits related to this issue

Most upvoted comments

@campbecf: there are different defaults. Puppeteer defaults printBackground to false, whereas chrome has it set to true by default.

There are also other defaults, like margins, which you can tweak to achieve the same results.

@campbecf how does your PDF has 2 pages split according to the content . Sorry for asking it in here . Can you please help me here. I am successfully able to PDF a long pages of content but in a single page . I wanted to split it like your example pdf according to content.