I'm having trouble making the PDF.js library render a PDF to a PNG file.
My steps are :
mkdir pdf-testnpm initnpm install pdfjs-dist assert canvas- Copy
pdf2png.jsfrom the examples page to the working folder - Copy a random PDF to this folder, set path to it in
pdf2png.json line 54 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
Surprisingly, if I clone the entire PDF.js repository and follow the instructions to build it from source, the script work fine and I get a correctly rendered PNG file.
What am I missing when installing a prebuilt version from NPM?
from "Invalid canvas size" while rendering PDF to PNG using pdf.js
No comments:
Post a Comment