mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Support Optional Content in Image-/XObjects (issue 13931)
Currently, in the `PartialEvaluator`, we only support Optional Content in Form-/XObjects. Hence this patch adds support for Image-/XObjects as well, which looks like a simple oversight in PR 12095 since the canvas-implementation already contains the necessary code to support this.
This commit is contained in:
parent
ada283cc35
commit
853b1172a1
4 changed files with 32 additions and 5 deletions
|
@ -567,12 +567,21 @@ class PartialEvaluator {
|
|||
|
||||
if (!(w && isNum(w)) || !(h && isNum(h))) {
|
||||
warn("Image dimensions are missing, or not numbers.");
|
||||
return undefined;
|
||||
return;
|
||||
}
|
||||
const maxImageSize = this.options.maxImageSize;
|
||||
if (maxImageSize !== -1 && w * h > maxImageSize) {
|
||||
warn("Image exceeded maximum allowed size and was removed.");
|
||||
return undefined;
|
||||
return;
|
||||
}
|
||||
|
||||
let optionalContent = null;
|
||||
if (dict.has("OC")) {
|
||||
optionalContent = await this.parseMarkedContentProps(
|
||||
dict.get("OC"),
|
||||
resources
|
||||
);
|
||||
operatorList.addOp(OPS.beginMarkedContentProps, ["OC", optionalContent]);
|
||||
}
|
||||
|
||||
const imageMask = dict.get("ImageMask", "IM") || false;
|
||||
|
@ -610,7 +619,11 @@ class PartialEvaluator {
|
|||
args,
|
||||
});
|
||||
}
|
||||
return undefined;
|
||||
|
||||
if (optionalContent) {
|
||||
operatorList.addOp(OPS.endMarkedContent, []);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const softMask = dict.get("SMask", "SM") || false;
|
||||
|
@ -631,7 +644,11 @@ class PartialEvaluator {
|
|||
// any other kind.
|
||||
imgData = imageObj.createImageData(/* forceRGBA = */ true);
|
||||
operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
|
||||
return undefined;
|
||||
|
||||
if (optionalContent) {
|
||||
operatorList.addOp(OPS.endMarkedContent, []);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// If there is no imageMask, create the PDFImage and a lot
|
||||
|
@ -699,7 +716,10 @@ class PartialEvaluator {
|
|||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
|
||||
if (optionalContent) {
|
||||
operatorList.addOp(OPS.endMarkedContent, []);
|
||||
}
|
||||
}
|
||||
|
||||
handleSMask(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue