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

Take into account the group bbox

It fixes #16742.
This commit is contained in:
Calixte Denizet 2025-03-23 19:19:58 +01:00
parent bcba053a5e
commit a3c31904f1
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({