You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It generates a runtime error when running node index.js:
file:///home/soadzoor/works/node-pdfjs/node_modules/pdfjs-dist/build/pdf.mjs:6910
if (imgData instanceof ImageData) {
^
ReferenceError: ImageData is not defined
at putBinaryImageData (file:///home/soadzoor/works/node-pdfjs/node_modules/pdfjs-dist/build/pdf.mjs:6910:26)
at CanvasGraphics.paintInlineImageXObject (file:///home/soadzoor/works/node-pdfjs/node_modules/pdfjs-dist/build/pdf.mjs:8505:7)
at CanvasGraphics.paintImageXObject (file:///home/soadzoor/works/node-pdfjs/node_modules/pdfjs-dist/build/pdf.mjs:8431:10)
at CanvasGraphics.executeOperatorList (file:///home/soadzoor/works/node-pdfjs/node_modules/pdfjs-dist/build/pdf.mjs:7177:20)
at InternalRenderTask._next (file:///home/soadzoor/works/node-pdfjs/node_modules/pdfjs-dist/build/pdf.mjs:13056:37)
Link to a viewer
No response
Additional context
After the fix was released for #19145 , I was really excited to give it a shot again, but now it says a different runtime error (see above), when I try to run it in node.js environment.
I guess ImageData is not available in node.js, so we need an additional check before running that condition, to see whether we're in nodejs, or in browser.
I can confirm that if I replace this line: if (imgData instanceof ImageData) {
with this line: if (!isNodeJS && imgData instanceof ImageData) {
everything seems to be working fine
The text was updated successfully, but these errors were encountered:
Attach (recommended) or Link to PDF file
https://github.com/mozilla/pdf.js/files/13179307/c53a656b-551d-4c24-bfb6-f994ef3a6d4b.pdf
But I believe it has nothing to do with the PDF file itself.
Web browser and its version
Node.js v22.11.0
Operating system and its version
Ubuntu 22.04.2 LTS (but I tried with newest MacOS as well, same issue...)
PDF.js version
4.9.155
Is the bug present in the latest PDF.js version?
Yes
Is a browser extension
No
Steps to reproduce the problem
What is the expected behavior?
It should generate a PNG file
What went wrong?
It generates a runtime error when running node index.js:
file:///home/soadzoor/works/node-pdfjs/node_modules/pdfjs-dist/build/pdf.mjs:6910
if (imgData instanceof ImageData) {
^
ReferenceError: ImageData is not defined
at putBinaryImageData (file:///home/soadzoor/works/node-pdfjs/node_modules/pdfjs-dist/build/pdf.mjs:6910:26)
at CanvasGraphics.paintInlineImageXObject (file:///home/soadzoor/works/node-pdfjs/node_modules/pdfjs-dist/build/pdf.mjs:8505:7)
at CanvasGraphics.paintImageXObject (file:///home/soadzoor/works/node-pdfjs/node_modules/pdfjs-dist/build/pdf.mjs:8431:10)
at CanvasGraphics.executeOperatorList (file:///home/soadzoor/works/node-pdfjs/node_modules/pdfjs-dist/build/pdf.mjs:7177:20)
at InternalRenderTask._next (file:///home/soadzoor/works/node-pdfjs/node_modules/pdfjs-dist/build/pdf.mjs:13056:37)
Link to a viewer
No response
Additional context
After the fix was released for #19145 , I was really excited to give it a shot again, but now it says a different runtime error (see above), when I try to run it in node.js environment.
I guess
ImageData
is not available in node.js, so we need an additional check before running that condition, to see whether we're in nodejs, or in browser.I can confirm that if I replace this line:
if (imgData instanceof ImageData) {
with this line:
if (!isNodeJS && imgData instanceof ImageData) {
everything seems to be working fine
The text was updated successfully, but these errors were encountered: