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

Compatibility with Node v16+ #20

Closed
MonkOfTheFeels opened this issue Aug 7, 2022 · 5 comments · Fixed by #22
Closed

Compatibility with Node v16+ #20

MonkOfTheFeels opened this issue Aug 7, 2022 · 5 comments · Fixed by #22

Comments

@MonkOfTheFeels
Copy link

MonkOfTheFeels commented Aug 7, 2022

Hey there,

I am running the following code in a docker container with Canvas successfully installed (at least my understanding based on install steps mentioned in other issues).

import { pdfToPng } from 'pdf-to-png-converter';
import { readFileSync } from 'node:fs';

a = readFileSync('routes/test_pdf/1650457668823.pdf')
pngPages = pdfToPng( a, {viewportScale: 1.0})

I am getting the following error and can't for the life of me understand whats wrong.

node: ../../nan/nan_object_wrap.h:32: static T* Nan::ObjectWrap::Unwrap(v8::Local<v8::Object>) [with T = Context2d]: Assertion object->InternalFieldCount() > 0' failed. Aborted

Any help would be greatly appreciated.

@MonkOfTheFeels MonkOfTheFeels changed the title Error when running pdfToPng Error Importing pdfToPng using ES6 Aug 12, 2022
@dichovsky
Copy link
Owner

Hey there,

Please specify more details about the issue, OS, Node version, etc.
Try to specify file path to the function, you don't need to read file beforehand.

@proasync
Copy link

proasync commented Aug 24, 2022

I also get the error:
node: ../../nan/nan_object_wrap.h:32: static T* Nan::ObjectWrap::Unwrap(v8::Local<v8::Object>) [with T = Context2d]: Assertionobject->InternalFieldCount() > 0' failed.`

My code:
import { pdfToPng, PngPageOutput } from 'pdf-to-png-converter';

const pdfBuffer = Buffer.from(pdfDoc, 'base64');
const pngPages: PngPageOutput[] = await pdfToPng(pdfBuffer, { viewportScale: 1.0 });

My setup:
OS: Arch Linux
Kernel: 5.18.12-arch1-1
Node version: v18.6.0

Thanks for the effort with this repo.

@dichovsky
Copy link
Owner

At this moment pdf-to-png-converter is not able to work on Node version: v18, you should use v16

@MonkOfTheFeels MonkOfTheFeels changed the title Error Importing pdfToPng using ES6 Compatibility with Node v16+ Aug 25, 2022
@MonkOfTheFeels
Copy link
Author

MonkOfTheFeels commented Aug 25, 2022

That was what was causing my issue then as I am using node v18. Thanks so much both of you for the help with this!

My setup
Kernal: 5.10.102.1-microsoft-standard-WSL2 x86_64
Node Version: v18.7.0

I have updated the issue name to be clear on the cause of the issue.

@EHadoux
Copy link
Contributor

EHadoux commented Nov 4, 2022

That issue was due to Automattic/node-canvas#2025 now it's fixed with v2.10.2, maybe we can not use strict versions in package.json? Likewise pdfjs-dist has released a new major version.

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

Successfully merging a pull request may close this issue.

4 participants