pdf2json
pdf2json copied to clipboard
Trying to parse a file upload
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), …}
seems like a buffer issue, please test it with latest master (v3.1.5 w/ https://github.com/modesty/pdf2json/commit/bcbebdbb3f6aec20713d300596bd0ea06f2e5918 )