Skip to content

Commit b57da32

Browse files
authored
Merge pull request #19716 from calixteman/issue16742
Take into account the group bbox
2 parents fceaab8 + a3c3190 commit b57da32

4 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/display/canvas.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ class CanvasGraphics {
13801380
this.suspendedCtx = this.ctx;
13811381
this.ctx = scratchCanvas.context;
13821382
const ctx = this.ctx;
1383-
ctx.setTransform(...getCurrentTransform(this.suspendedCtx));
1383+
ctx.setTransform(this.suspendedCtx.getTransform());
13841384
copyCtxState(this.suspendedCtx, ctx);
13851385
mirrorContextOperations(ctx, this.suspendedCtx);
13861386

@@ -2551,6 +2551,17 @@ class CanvasGraphics {
25512551
groupCtx.translate(-offsetX, -offsetY);
25522552
groupCtx.transform(...currentTransform);
25532553

2554+
// Apply the bbox to the group context.
2555+
let clip = new Path2D();
2556+
const [x0, y0, x1, y1] = group.bbox;
2557+
clip.rect(x0, y0, x1 - x0, y1 - y0);
2558+
if (group.matrix) {
2559+
const path = new Path2D();
2560+
path.addPath(clip, new DOMMatrix(group.matrix));
2561+
clip = path;
2562+
}
2563+
groupCtx.clip(clip);
2564+
25542565
if (group.smask) {
25552566
// Saving state and cached mask to be used in setGState.
25562567
this.smaskStack.push({

test/pdfs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,3 +716,4 @@
716716
!issue19633.pdf
717717
!issue19424.pdf
718718
!issue18529.pdf
719+
!issue16742.pdf

test/pdfs/issue16742.pdf

2.52 KB
Binary file not shown.

test/test_manifest.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12019,5 +12019,12 @@
1201912019
"md5": "f95d2cbdd904f5acf922e088cc3cb153",
1202012020
"rounds": 1,
1202112021
"type": "eq"
12022+
},
12023+
{
12024+
"id": "issue16742",
12025+
"file": "pdfs/issue16742.pdf",
12026+
"md5": "98b19e944339c01c10c503685eee3ad2",
12027+
"rounds": 1,
12028+
"type": "eq"
1202212029
}
1202312030
]

0 commit comments

Comments
 (0)