-
Notifications
You must be signed in to change notification settings - Fork 48
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
Does not work with electron #1
Comments
I think I will just take some inspiration from your code and switch the canvas by a real canvas. Btw, I would suggest to change that pdfData = new Uint8Array(fs.readFileSync(pdfURL)); by import util from 'util'
const readFile= util.promisify(fs.readFile);
...
pdfData = new Uint8Array(await readFile(pdfURL)); |
Thanks for pointing this out. I'd only tested it on pure node and chose node-canvas accordingly. I'll try to find a workaround for this but in the meantime feel free to fork the repo and make the necessary changes for your use case. (Please do submit a PR if you find a solution that works for node too 🙂)
I'll make this change you suggested here - thanks for pointing this out too. |
Hi guys, |
@Yarin4 just to double check - did you rebuild it against electron using If you rebuilt against node could you try rebuilding against electron and reporting back? It'd be really useful thanks. |
I used electron-rebuild but I actually think I am missing a package I'll have to check again |
Same issue for me |
when I used electron-rebuild, it fails and reports an error.
|
You should update to master branch of node-canvas (v3.0.0) v2 has a lot of build issues with electron rebuild. The update also requires updating pdfjs-dist's canvas dependency to master branch as well, so I used a fork. https://github.com/Automattic/node-canvas Run this to fix: Specifically on windows, the canvas node depends on multiple dll files so I just added this with webpack copy plugin. let copyPatterns = []
if (process.platform === "win32") {
copyPatterns.push(...[
{from: "node_modules/canvas/build/Release/jpeg62.dll", to: "[name][ext]"},
{from: "node_modules/canvas/build/Release/libcairo-2.dll", to: "[name][ext]"},
{from: "node_modules/canvas/build/Release/libexpat-1.dll", to: "[name][ext]"},
{from: "node_modules/canvas/build/Release/libfontconfig-1.dll", to: "[name][ext]"},
{from: "node_modules/canvas/build/Release/libfreetype-6.dll", to: "[name][ext]"},
{from: "node_modules/canvas/build/Release/libglib-2.0-0.dll", to: "[name][ext]"},
{from: "node_modules/canvas/build/Release/libgmodule-2.0-0.dll", to: "[name][ext]"},
{from: "node_modules/canvas/build/Release/libgobject-2.0-0.dll", to: "[name][ext]"},
{from: "node_modules/canvas/build/Release/libgthread-2.0-0.dll", to: "[name][ext]"},
{from: "node_modules/canvas/build/Release/libintl-8.dll", to: "[name][ext]"},
{from: "node_modules/canvas/build/Release/libpango-1.0-0.dll", to: "[name][ext]"},
{from: "node_modules/canvas/build/Release/libpangocairo-1.0-0.dll", to: "[name][ext]"},
{from: "node_modules/canvas/build/Release/libpangoft2-1.0-0.dll", to: "[name][ext]"},
{from: "node_modules/canvas/build/Release/libpangowin32-1.0-0.dll", to: "[name][ext]"},
{from: "node_modules/canvas/build/Release/libpng14-14.dll", to: "[name][ext]"},
{from: "node_modules/canvas/build/Release/zlib1.dll", to: "[name][ext]"}
])
}
// add plugin
new CopyPlugin({
patterns: copyPatterns
}) |
for 2.0.0 .../dist/fa782d78b72b06e169fa60a7d72fbab8.node' |
Description
I like the idea of this lib, and I was surprised to see someone else working on the same thing few hours ago 😄
Apparently the dependence to
canvas
caused issues with other flavor of JS like electronSeems like only node binding are managed
The text was updated successfully, but these errors were encountered: