clarekang / form-pdf2json

NodeJS library to convert JSON to PDF or vice versa
MIT License
8 stars 2 forks source link

pdf2json.convertPdf2Json not a function? #5

Open AdamMarciniak opened 3 years ago

AdamMarciniak commented 3 years ago

I've got code like so:

var pdf2json = require('form-pdf2json')

console.log(pdf2json.convertPdf2Json('formExample.pdf'))

And it gives me :

TypeError: pdf2json.convertPdf2Json is not a function

Is there something I can do to fix this?

clarekang commented 3 years ago

Hi, It seems to be an error caused by the class not being declared correctly. I think you should change your code like this:

var Pdf2json = require('form-pdf2json');
var pdf2Json = new Pdf2Json();
console.log(pdf2json.convertPdf2Json('formExample.pdf'));

It's been a while since I've seen this code, so I need to check it a lil bit. 😅 But anytime ask me if you have any questions.

sanatg commented 2 years ago

Hi tried using the code above @ClareKang:

var Pdf2json = require('form-pdf2json'); var pdf2Json = new Pdf2Json(); console.log(pdf2json.convertPdf2Json('./test.pdf'));

but i got an error:

node:internal/fs/utils:344 throw err; ^ Error: ENOENT: no such file or directory, scandir 'files/'

what can i do to resolve it?

Matojeje commented 1 year ago

Same issue here

clarekang commented 1 year ago

I'll check this issue again

steveharman commented 1 year ago

Similar issue for me.

With the following:

var pdf2json = require("form-pdf2json");
pdf2json.convertPdf2Json("/Users/steveharman/sampleForm.pdf");
pdf2json.exportPdf2Json("/Users/steveharman/sampleForm.json");

When I issue node ./myscript.js (that ^^) I get:

Error: ENOENT: no such file or directory, scandir 'files/'

Thanks