-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
[Bug]: electron-vite (node) Cannot read properties of undefined (reading 'createCanvas') #19047
Comments
|
Thanks for your PR rewriting this part of the code with the newer dependency, I hope it solves the issue. If it doesn't I'm happy to make a PR if y'all welcome them, although I'm new to the codebase. This isn't about electron, which is why I opened the new issue. It's about sveltekit running a normal web app, although the error points to an issue that likely spans nextjs or any SSR node based framework where you're doing server side calls to the canvas factory. |
I'm confused why this is being closed and why the other issue is being moved to a discussion. There is an example here: https://github.com/mozilla/pdf.js/blob/master/examples/node/pdf2png/pdf2png.mjs that reproduces this exact error on an express server. Edit, looks like the issue was fixed here: #19015 Is there a timeline for the next release? |
Agree, if it's helpful we ended up downgrading to |
Discussed in #18981
There is a bug with the node import code in pdfjs-dist that is causing the imports to fail for canvas in node. This is observed working in node with vite/sveltekit. The source of the bug is in the code in pdfjs-dist which does dynamic imports for node. In my case it fails to define an import for canvas or path2d, and calling
NodeCanvasFactory
(as is done in the node example) gives the error reported in the original issue.Originally posted by fenicento October 30, 2024
Attach (recommended) or Link to PDF file
sample.pdf
Web browser and its version
nodejs
Operating system and its version
windows 11
PDF.js version
4.7.76
Is the bug present in the latest PDF.js version?
Yes
Is a browser extension
No
Steps to reproduce the problem
when trying to render a pdf page on canvas, i get the following error:
What is the expected behavior?
it should correctly render the page and save it to a buffer
What went wrong?
file is correctly read, number of pages and viewport are correctly reported, but the render call fails:
Link to a viewer
No response
Additional context
this is the conversion function I wrote:
this is the package.json:
The text was updated successfully, but these errors were encountered: