1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +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({

View file

@ -716,3 +716,4 @@
!issue19633.pdf
!issue19424.pdf
!issue18529.pdf
!issue16742.pdf

189
test/pdfs/issue16742.pdf Normal file
View file

@ -0,0 +1,189 @@
%PDF-1.7
%€€€€
1 0 obj
<<
/Type /Catalog
/Pages 2 0 R
>>
endobj
2 0 obj
<<
/Type /Pages
/Count 1
/Kids [3 0 R]
>>
endobj
6 0 obj
<<
/Length 105
/Type /XObject
/Subtype /Form
/Resources <<
/ColorSpace <<
/srgb [/CalRGB <<
/WhitePoint [0.9505 1 1.0888]
/Gamma [2.2 2.2 2.2]
/Matrix [0.4124 0.2126 0.0193 0.3576 0.715 0.1192 0.1805 0.0722 0.9505]
>>]
>>
/ProcSet [/PDF /ImageC /ImageB]
>>
/Group <<
/Type /Group
/S /Transparency
/I true
/K false
/CS [/CalRGB <<
/WhitePoint [0.9505 1 1.0888]
/Gamma [2.2 2.2 2.2]
/Matrix [0.4124 0.2126 0.0193 0.3576 0.715 0.1192 0.1805 0.0722 0.9505]
>>]
>>
/BBox [-20 -20 80 220.00002]
>>
stream
q
q
1 0 0 1 0 0 cm
q
1 0 0 1 0 0 cm
/srgb CS
/srgb cs
1 1 1 scn
0 0 m
200 0 l
200 200 l
0 200 l
h
f
Q
Q
Q
endstream
endobj
7 0 obj
<<
/Type /ExtGState
/SMask <<
/Type /Mask
/S /Luminosity
/G 6 0 R
>>
>>
endobj
5 0 obj
<<
/Length 174
/Type /XObject
/Subtype /Form
/Resources <<
/ColorSpace <<
/srgb [/CalRGB <<
/WhitePoint [0.9505 1 1.0888]
/Gamma [2.2 2.2 2.2]
/Matrix [0.4124 0.2126 0.0193 0.3576 0.715 0.1192 0.1805 0.0722 0.9505]
>>]
>>
/ProcSet [/PDF /ImageC /ImageB]
/ExtGState <<
/gs0 7 0 R
>>
>>
/BBox [0 0 200 200]
/Group <<
/Type /Group
/S /Transparency
/I true
/K false
/CS [/CalRGB <<
/WhitePoint [0.9505 1 1.0888]
/Gamma [2.2 2.2 2.2]
/Matrix [0.4124 0.2126 0.0193 0.3576 0.715 0.1192 0.1805 0.0722 0.9505]
>>]
>>
>>
stream
q
1 0 0 -1 0 200 cm
q
0.9848077 0.17364818 -0.17364818 0.9848077 0 0 cm
/gs0 gs
q
1 0 0 1 0 0 cm
/srgb CS
/srgb cs
0 0.5019608 0 scn
0 0 m
200 0 l
200 200 l
0 200 l
h
f
Q
Q
Q
endstream
endobj
4 0 obj
<<
/Length 7
>>
stream
/xo0 Do
endstream
endobj
3 0 obj
<<
/Type /Page
/Resources <<
/ColorSpace <<
/srgb [/CalRGB <<
/WhitePoint [0.9505 1 1.0888]
/Gamma [2.2 2.2 2.2]
/Matrix [0.4124 0.2126 0.0193 0.3576 0.715 0.1192 0.1805 0.0722 0.9505]
>>]
>>
/ProcSet [/PDF /ImageC /ImageB]
/XObject <<
/xo0 5 0 R
>>
>>
/MediaBox [0 0 200 200]
/Parent 2 0 R
/Contents 4 0 R
>>
endobj
8 0 obj
<<
/Producer (svg2pdf)
>>
endobj
xref
0 9
0000000000 65535 f
0000000016 00000 n
0000000070 00000 n
0000001875 00000 n
0000001816 00000 n
0000000977 00000 n
0000000134 00000 n
0000000871 00000 n
0000002275 00000 n
trailer
<<
/Size 9
/Root 1 0 R
/Info 8 0 R
>>
startxref
2319
%%EOF

View file

@ -12019,5 +12019,12 @@
"md5": "f95d2cbdd904f5acf922e088cc3cb153",
"rounds": 1,
"type": "eq"
},
{
"id": "issue16742",
"file": "pdfs/issue16742.pdf",
"md5": "98b19e944339c01c10c503685eee3ad2",
"rounds": 1,
"type": "eq"
}
]