Skip to content

Instantly share code, notes, and snippets.

@IanShoe
Created February 17, 2016 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IanShoe/e92ee20f4862b187f9ae to your computer and use it in GitHub Desktop.
Save IanShoe/e92ee20f4862b187f9ae to your computer and use it in GitHub Desktop.
pdf error being eaten
var Parser = require('pdf2json/pdfparser');
var pdfParser = new Parser();
function handler(err, data) {
if (err) {
console.log('Normal Error Here');
} else if(data) {
console.log('We have data, we will now continue with our app');
throw new Error('Something about our app itself blows up and we should see this bubble up');
}
}
pdfParser.on('pdfParser_dataReady', function(evtData) {
if (!!evtData && !!evtData.data) {
handler(null, evtData.data);
} else {
handler('Error parsing file');
}
});
pdfParser.on('pdfParser_dataError', function(evtData) {
var err = evtData.data;
console.log('Error parsing file', err);
handler(err);
});
pdfParser.loadPDF('path/to/valid/doc.pdf');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment