1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 01:58:06 +02:00

[api-minor] Add a getDocument parameter that allows disabling of the NativeImageDecoder (e.g. for use with Node.js)

Note that I initially tried to add this as a parameter to the `PDFPageProxy.render` method, such that it could be passed to `PartialEvaluator.getOperatorList`.
However, given all the different code-paths that call `getOperatorList` (there's a bunch only in `annotation.js`), this seemed to very quickly become unwieldy and thus difficult to maintain compared to simply using the existing `evaluatorOptions`.
This commit is contained in:
Jonas Jenwald 2017-02-06 22:09:19 +01:00
parent 3e5c6e4287
commit 9c34d0aa8c
3 changed files with 16 additions and 5 deletions

View file

@ -112,7 +112,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
forceDataSchema: false,
maxImageSize: -1,
disableFontFace: false,
cMapOptions: { url: null, packed: false }
cMapOptions: { url: null, packed: false },
disableNativeImageDecoder: false,
};
function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
@ -388,13 +389,15 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
return;
}
var useNativeImageDecoder = !this.options.disableNativeImageDecoder;
// If there is no imageMask, create the PDFImage and a lot
// of image processing can be done here.
var objId = 'img_' + this.idFactory.createObjId();
operatorList.addDependency(objId);
args = [objId, w, h];
if (!softMask && !mask && image instanceof JpegStream &&
if (useNativeImageDecoder &&
!softMask && !mask && image instanceof JpegStream &&
NativeImageDecoder.isSupported(image, this.xref, resources)) {
// These JPEGs don't need any more processing so we can just send it.
operatorList.addOp(OPS.paintJpegXObject, args);
@ -406,8 +409,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// Creates native image decoder only if a JPEG image or mask is present.
var nativeImageDecoder = null;
if (image instanceof JpegStream || mask instanceof JpegStream ||
softMask instanceof JpegStream) {
if (useNativeImageDecoder &&
(image instanceof JpegStream || mask instanceof JpegStream ||
softMask instanceof JpegStream)) {
nativeImageDecoder = new NativeImageDecoder(self.xref, resources,
self.handler, self.options.forceDataSchema);
}