Merge f0964c7dfde6c0c8c006b55c5ed0cdd2bc131554 into ec71e4ed651e659b06a4fa46ef0b18ff9ab2a8c7

This commit is contained in:
zenocross 2025-11-25 15:21:08 -05:00 committed by GitHub
commit 9a8641a59a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 42 additions and 0 deletions

View File

@ -511,6 +511,27 @@ class PartialEvaluator {
smask.backdrop = colorSpace.getRgbHex(smask.backdrop, 0);
}
// Parse group blend mode from ExtGState if it's in FormX Resources
const localResources = dict.get("Resources");
if (localResources instanceof Dict) {
const extGState = localResources.get("ExtGState");
if (extGState instanceof Dict) {
for (const val of extGState.getRawValues()) {
if (val instanceof Dict && val.has("BM")) {
const blendMode = val.get("BM");
if (blendMode != null) {
try {
groupOptions.blendMode = normalizeBlendMode(blendMode);
break;
} catch (ex) {
console.error(`Invalid blend mode in ExtGState: ${blendMode}`, ex);
}
}
}
}
}
}
operatorList.addOp(OPS.beginGroup, [groupOptions]);
}

View File

@ -2700,7 +2700,12 @@ class CanvasGraphics {
currentMtx,
dirtyBox
);
// Apply the group blend mode and alpha when compositing the group
const prevBlendMode = this.pushGroupBlendMode(this.ctx, group.blendMode);
this.ctx.drawImage(groupCtx.canvas, 0, 0);
this.popGroupBlendMode(this.ctx, prevBlendMode);
this.ctx.restore();
this.compose(dirtyBox);
}
@ -3336,6 +3341,22 @@ class CanvasGraphics {
}
}
pushGroupBlendMode(ctx, blendMode) {
if (!ctx || !blendMode) {
return null;
}
const prev = ctx.globalCompositeOperation;
ctx.globalCompositeOperation = blendMode;
return prev;
}
popGroupBlendMode(ctx, prev) {
if (ctx && prev !== null) {
ctx.globalCompositeOperation = prev;
}
}
isContentVisible() {
for (let i = this.markedContentStack.length - 1; i >= 0; i--) {
if (!this.markedContentStack[i].visible) {