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 error - 18 page PDF

See original GitHub issue

Tell us about your environment:

  • Puppeteer version: 1.4.0
  • Platform / OS version: Ubuntu 16.04.4 LTS
  • URLs (if applicable):
  • Node.js version: v8.11.2

This works fine for smaller PDFs / pages, but fails, pretty consistently, for an 18-page PDF (statement report). It is relatively small considering the amount of pages (about 88KB). I was able to get it to work once, but have not been able to replicate this success.

What steps will reproduce the problem?

Various versions of the following

/test

          const browser = await puppeteer.launch()
          const page = await browser.newPage()

          await page.goto('http://pms.dasaproperties.com/test-owner-statement.html', { waitUntil: 'networkidle2' })
          const doc = await page.pdf({path: '/tmp/random-page.pdf', landscape: false, format: 'letter', printBackground: true})

          await browser.close()
          return h.file('/tmp/random-page.pdf').vary('x-magic');

-or-

          const browser = await puppeteer.launch()
          const page = await browser.newPage()

          await page.goto('http://pms.dasaproperties.com/test-owner-statement.html', { waitUntil: 'networkidle2' })
          const doc = await page.pdf({landscape: false, format: 'letter', printBackground: true})

          await browser.close()
          return h.response(doc).type('application/pdf')

What is the expected result?

A resulting PDF. Like the following using PhantomJS: http://snapper.webcmstools.com/pdf?url=http://pms.dasaproperties.com/test-owner-statement.html

What happens instead?

The following errors:

May 21 21:11:59 snapper[14335]: { Error: Protocol error (Page.printToPDF): Target closed. May 21 21:11:59 snapper[14335]: at Promise (/srv/snapper/node_modules/puppeteer/lib/Connection.js:200:56) May 21 21:11:59 snapper[14335]: at new Promise (<anonymous>) May 21 21:11:59 snapper[14335]: at CDPSession.send (/srv/snapper/node_modules/puppeteer/lib/Connection.js:199:12) May 21 21:11:59 snapper[14335]: at Page.pdf (/srv/snapper/node_modules/puppeteer/lib/Page.js:798:39) May 21 21:11:59 snapper[14335]: at handler (/srv/snapper/src/screenshots.js:35:34) May 21 21:11:59 snapper[14335]: at <anonymous> May 21 21:11:59 snapper[14335]: at process._tickCallback (internal/process/next_tick.js:188:7) message: ‘Protocol error (Page.printToPDF): Target closed.’ }

Issue Analytics

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

github_iconTop GitHub Comments

6reactions
mtwhelancommented, May 22, 2018

Closing this. We figured out what was causing the problem, and it had nothing to do with the fact that the PDF was 18 pages long. I will open a new issue if necessary. Thanks!

2reactions
njriordancommented, May 22, 2018

@mtwhelan do you have any more information? I’m experiencing the same issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

there was an error processing a page. there was a
there was a problem reading this document(18)' error when i open a PDF in a certain page( the image that exists does not...
Read more >
Problem reading (18) | Adobe Acrobat
I can't answer as to why it happens but my workaround is to 'Reduce File Size' and change the Reader Level then resave...
Read more >
SOLUTION ! There was an error opening this document. There ...
This is a native PDF document. This should not happen. I am using Acrobat built-in functionality, and this breaks the index, breaks the...
Read more >
[SOLVED] WF 769, 1-page PDF report giving error 18 - Topic
Chances are there is a problem with the report itself and has nothing to do with pdf. Try outputing as html and see...
Read more >
Fix: Adobe Acrobat Couldn't Read This Document - Technipages
To fix the problematic file, extract its pages to a new document. You can also use the “Print to PDF” or “Export to...
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