diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 207cdc101..2ad04dbca 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -80,11 +80,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { var colorSpace = dict.get('ColorSpace', 'CS'); colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources, this.pdfFunctionFactory); - var numComps = colorSpace.numComps; - var decodePromise = this.handler.sendWithPromise('JpegDecode', - [image.getIR(this.forceDataSchema), numComps]); - return decodePromise.then(function (message) { - var data = message.data; + + return this.handler.sendWithPromise('JpegDecode', [ + image.getIR(this.forceDataSchema), colorSpace.numComps + ]).then(function({ data, width, height, }) { return new Stream(data, 0, data.length, image.dict); }); }, diff --git a/src/core/image.js b/src/core/image.js index 9fa090365..bd1896802 100644 --- a/src/core/image.js +++ b/src/core/image.js @@ -27,7 +27,11 @@ var PDFImage = (function PDFImageClosure() { */ function handleImageData(image, nativeDecoder) { if (nativeDecoder && nativeDecoder.canDecode(image)) { - return nativeDecoder.decode(image); + return nativeDecoder.decode(image).catch((reason) => { + warn('Native image decoding failed -- trying to recover: ' + + (reason && reason.message)); + return image; + }); } return Promise.resolve(image); }