question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

page.pdf First page not complete when too big and second page not print at all

See original GitHub issue

Steps to reproduce

What steps will reproduce the problem?

Here is the code that uses page.pdf()

const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://certificate-demo.bcdiploma.com/dev/index.html#/pdf/0CE409BCD5360E6BD2DDD1DBA0AF9D0E6B40658F8745870007EF027114F41BF0qEFaPHixFa8RTaL9zI4weB6%252F5aEK2RAOGgeo81ZJ3REeAOXR');
await page.waitFor(() => document.querySelector('.certificat-face--front'), {timeout:10000}) ;
await page.evaluate(() => {
        var buttons = document.getElementsByClassName('certificat-sticky-buttons');
        for (var i = 0; i < buttons.length; i++) {     buttons[i].style.display = "none";        }
        buttons = document.getElementsByClassName('certificat-button-wrapper');
        for (var i = 0; i < buttons.length; i++) {          buttons[i].style.display = "none";        }
        buttons = document.getElementsByClassName('ignorePDF');
        for (var i = 0; i < buttons.length; i++) {          buttons[i].style.display = "none";        }
        buttons = document.getElementsByClassName('click');
        for (var i = 0; i < buttons.length; i++) {          buttons[i].style.display = "none";        }
        buttons = document.getElementsByTagName('button');
        for (var i = 0; i < buttons.length; i++) {          buttons[i].style.display = "none";        }
      });
await page.addStyleTag(        {'content': '@page {size: auto}'}      );
await page.emulateMedia('screen');
await page.pdf({path: 'screenshot.pdf',format: 'A4', landscape: true, printBackground: true, scale: 0.7});
await browser.close();

What is the expected result?

In the target url, I have two divs with the 'page-break-after: always;' style, which are supposed to be displayed on each pages. I expect to get a PDF file with two pages, one for each div section.

What happens instead?

I only got one page, the second one is not print at all, although it is displayed correctly in chromium.

When the first div is too big, it is truncated in the pdf file. This is normal when the option format: 'A4' is set, but it is happening even when it it not.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:6

github_iconTop GitHub Comments

4reactions
PunkHaz4rdcommented, Aug 2, 2019

Same

0reactions
stale[bot]commented, Jul 25, 2022

We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

page.pdf First page not complete when too big and second ...
I only got one page, the second one is not print at all, although it is displayed correctly in chromium. When the first...
Read more >
Troubleshoot PDF printing in Acrobat and Reader
Try printing this troubleshooting page. If you can't, follow these steps to check your connection to the printer:.
Read more >
PDF displays correctly in Adobe Reader, but doesn't print ...
Answer: If the PDF displays correctly but prints on a paper printer incorrectly, it's most often a issue with Adobe Reader or the...
Read more >
Word does not Print page range, only full document 2021
This issue occurs if the page number does not match the number of pages for custom printing. It is recommended to generate consecutive...
Read more >
Choose a paper size for your printed document on Mac
In apps such as Pages or Microsoft Word, you can also specify a page size for a document as you're working on it....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found