Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

“Invalid canvas size” in "PDF to PNG" example #10778

Closed
impworks opened this issue Apr 30, 2019 · 2 comments
Closed

“Invalid canvas size” in "PDF to PNG" example #10778

impworks opened this issue Apr 30, 2019 · 2 comments

Comments

@impworks
Copy link

Trying to render a PNG from the PDF file using the example.

Steps to reproduce:

  1. mkdir pdf-test
  2. npm init
  3. npm install pdfjs-dist assert canvas
  4. Copy pdf2png.js from the examples page to the working folder
  5. Copy a random PDF to this folder, set path to it in pdf2png.js on line 54
  6. node pdf2png.js

I'm getting the following output:

# PDF document loaded.
(node:13760) UnhandledPromiseRejectionWarning: AssertionError [ERR_ASSERTION]: Invalid canvas size
    at NodeCanvasFactory_create [as create] (D:\tests\pdf-test\pdf2png.js:23:5)
    at D:\tests\pdf-test\pdf2png.js:70:21

My system:

  • Windows 10 x64
  • Node v11.6.0
  • npm v6.5.0-next.0

Surprisingly, if I clone the entire PDF.js repository and follow the instructions to build it from source, the script works fine and I get a correctly rendered PNG file.

What am I missing when installing a prebuilt version from NPM?

@stygmate
Copy link

stygmate commented May 7, 2019

+1

@impworks
Copy link
Author

impworks commented May 7, 2019

Turns out that NPM installs v2.0.943 by default, but there already is v2.1.226 where everything just works. Updating pdfjs-dist version manually resolved the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants