-
Notifications
You must be signed in to change notification settings - Fork 377
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
TypeError [ERR_INVALID_ARG_TYPE]: The "cb" argument must be of type function. Received undefined #309
Comments
"fs.writeFileSync("./test/bnr_01.json", JSON.stringify(pdfData));" you can edit the code in this way. |
This is an error in the docs of this library. |
this error coming when you forget a callback function . |
documentation updated, from the comments - modesty#309 (comment)
documentation updated, from the comments - #309 (comment)
For my case , cb argument not define was just a comma "," mistake when i was declaring my arguments in the fs.writeFile() check if you accedently put a dot instead of a comma "," |
MAC OS M1 Ventura 13.4.1
npm run test is happy:
11 input files 11 success 0 fail 0 warning
pdf2json@3.0.4 [https://github.com/modesty/pdf2json]: 479.797ms
./pdf/va/form : Expected: NO Exception, All Parsed OK
It takes 8 seconds to process all PDFs ...
but the json example is not:
`╰─⠠⠵ node bnr_01.js
node:internal/validators:440
throw new ERR_INVALID_ARG_TYPE(name, 'Function', value);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "cb" argument must be of type function. Received undefined
at maybeCallback (node:fs:177:3)
at Object.writeFile (node:fs:2272:14)
at PDFParser. (file:///Users/bnr01a/Documents/data/projects_current/pdf2json/bnr_01.js:8:8)
at PDFParser.emit (node:events:511:28)
at #onPDFJSParseDataReady (file:///Users/bnr01a/Documents/data/projects_current/pdf2json/node_modules/pdf2json/pdfparser.js:53:9)
at PDFJSClass. (file:///Users/bnr01a/Documents/data/projects_current/pdf2json/node_modules/pdf2json/pdfparser.js:69:77)
at PDFJSClass.emit (node:events:511:28)
at file:///Users/bnr01a/Documents/data/projects_current/pdf2json/node_modules/pdf2json/lib/pdf.js:221:38
at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
code: 'ERR_INVALID_ARG_TYPE'
}
Node.js v20.3.1
╭─~/Documents/data/projects_current/pdf2json on master✘✘✘ 23-07-26 10:43
╰─⠠⠵ cat bnr_01.js
import fs from "fs";
import PDFParser from "pdf2json";
const pdfParser = new PDFParser();
pdfParser.on("pdfParser_dataError", errData => console.error(errData.parserError) );
pdfParser.on("pdfParser_dataReady", pdfData => {
fs.writeFile("./test/bnr_01.json", JSON.stringify(pdfData));
});
pdfParser.loadPDF("./bnr_01.pdf")`
The text was updated successfully, but these errors were encountered: