1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

Merge pull request #19716 from calixteman/issue16742

Take into account the group bbox
This commit is contained in:
calixteman 2025-03-24 16:57:34 +01:00 committed by GitHub
commit b57da32d70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 209 additions and 1 deletions

View file

@ -1380,7 +1380,7 @@ class CanvasGraphics {
this.suspendedCtx = this.ctx;
this.ctx = scratchCanvas.context;
const ctx = this.ctx;
ctx.setTransform(...getCurrentTransform(this.suspendedCtx));
ctx.setTransform(this.suspendedCtx.getTransform());
copyCtxState(this.suspendedCtx, ctx);
mirrorContextOperations(ctx, this.suspendedCtx);
@ -2551,6 +2551,17 @@ class CanvasGraphics {
groupCtx.translate(-offsetX, -offsetY);
groupCtx.transform(...currentTransform);
// Apply the bbox to the group context.
let clip = new Path2D();
const [x0, y0, x1, y1] = group.bbox;
clip.rect(x0, y0, x1 - x0, y1 - y0);
if (group.matrix) {
const path = new Path2D();
path.addPath(clip, new DOMMatrix(group.matrix));
clip = path;
}
groupCtx.clip(clip);
if (group.smask) {
// Saving state and cached mask to be used in setGState.
this.smaskStack.push({