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
@ -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(
|
||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -442,6 +442,7 @@
|
||||
!issue8097_reduced.pdf
|
||||
!quadpoints.pdf
|
||||
!transparent.pdf
|
||||
!issue13931.pdf
|
||||
!xobject-image.pdf
|
||||
!issue6605.pdf
|
||||
!ccitt_EndOfBlock_false.pdf
|
||||
|
BIN
test/pdfs/issue13931.pdf
Normal file
BIN
test/pdfs/issue13931.pdf
Normal file
Binary file not shown.
@ -5019,6 +5019,12 @@
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue13931-default",
|
||||
"file": "pdfs/issue13931.pdf",
|
||||
"md5": "799d5025787115d22863ae23a3042491",
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue2829",
|
||||
"file": "pdfs/issue2829.pdf",
|
||||
"md5": "f32b28cf8792f6ccc470446bfbb38584",
|
||||
|
Loading…
Reference in New Issue
Block a user