pdf2json icon indicating copy to clipboard operation
pdf2json copied to clipboard

Trying to parse a file upload

Open scottswigart opened this issue 4 years ago • 1 comments
trafficstars

I'm getting an InvalidPDFException when trying to parse a PDF file upload:

var pdfParser = new PDFParser(this,1)
pdfParser.on("pdfParser_dataError", errData => console.error(errData.parserError) );
pdfParser.on("pdfParser_dataReady", pdfData => {
    console.log(pdfParser.getRawTextContent());
});
pdfParser.parseBuffer(req.files[file].buffer);

The file is uploading, and the buffer has data in it:

req.files[file] contains: {fieldname: 'test', originalname: 'test.pdf', encoding: '7bit', mimetype: 'application/pdf', buffer: Buffer(167518), …}

scottswigart avatar Dec 04 '20 21:12 scottswigart

seems like a buffer issue, please test it with latest master (v3.1.5 w/ https://github.com/modesty/pdf2json/commit/bcbebdbb3f6aec20713d300596bd0ea06f2e5918 )

modesty avatar Aug 17 '24 21:08 modesty