Closed elslooo closed 11 years ago
The problem is quite obvious actually:
function loadJpegStream(id, imageData, objs) {
var img = new Image();
img.onload = (function loadJpegStream_onloadClosure() {
objs.resolve(id, img);
});
img.src = 'data:image/jpeg;base64,' + window.btoa(imageData);
}
This only works in browsers of course, node does not implement an Image class. Out-commenting that block of code obviously also causes problems, because that way, the callback (objs.resolve(...)
) won't ever get called.
That's why I'm creating a fake "Image" class in pdf2json/pdf.js
.
I forked the repo in order to inspect the exact error:
The problem is: { message: 'Image is not defined', stack: 'ReferenceError: Image is not defined\n at loadJpegStream (eval at (/Users/Tim/EG Server/Source/Engine/eg-exam/node_modules/pdf2json/pdf.js:46:6))'
}
I'm looking into this issue and will add a pull request when I fixed it. :)