Skip to content

Commit ecc7096

Browse files
committed
Fix the default appearance of a Polygon annotation when a fill color is provided
It fixes #20062.
1 parent 729f2bb commit ecc7096

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

src/core/annotation.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4337,6 +4337,24 @@ class PolylineAnnotation extends MarkupAnnotation {
43374337
const strokeColor = this.color ? getPdfColorArray(this.color) : [0, 0, 0];
43384338
const strokeAlpha = dict.get("CA");
43394339

4340+
let fillColor = getRgbColor(dict.getArray("IC"), null);
4341+
if (fillColor) {
4342+
fillColor = getPdfColorArray(fillColor);
4343+
}
4344+
4345+
let operator;
4346+
if (fillColor) {
4347+
if (this.color) {
4348+
operator = fillColor.every((c, i) => c === strokeColor[i])
4349+
? "f"
4350+
: "B";
4351+
} else {
4352+
operator = "f";
4353+
}
4354+
} else {
4355+
operator = "S";
4356+
}
4357+
43404358
const borderWidth = this.borderStyle.width || 1,
43414359
borderAdjust = 2 * borderWidth;
43424360

@@ -4361,13 +4379,15 @@ class PolylineAnnotation extends MarkupAnnotation {
43614379
extra: `${borderWidth} w`,
43624380
strokeColor,
43634381
strokeAlpha,
4382+
fillColor,
4383+
fillAlpha: fillColor ? strokeAlpha : null,
43644384
pointsCallback: (buffer, points) => {
43654385
for (let i = 0, ii = vertices.length; i < ii; i += 2) {
43664386
buffer.push(
43674387
`${vertices[i]} ${vertices[i + 1]} ${i === 0 ? "m" : "l"}`
43684388
);
43694389
}
4370-
buffer.push("S");
4390+
buffer.push(operator);
43714391
return [points[0], points[7], points[2], points[3]];
43724392
},
43734393
});

test/pdfs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,3 +731,4 @@
731731
!bug1885505.pdf
732732
!bug1974436.pdf
733733
!firefox_logo.pdf
734+
!issue20062.pdf

test/pdfs/issue20062.pdf

5.42 KB
Binary file not shown.

test/test_manifest.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12164,5 +12164,12 @@
1216412164
"rounds": 1,
1216512165
"type": "eq",
1216612166
"annotations": true
12167+
},
12168+
{
12169+
"id": "issue20062",
12170+
"file": "pdfs/issue20062.pdf",
12171+
"md5": "9fa985242476c642464d94893528e40f",
12172+
"rounds": 1,
12173+
"type": "eq"
1216712174
}
1216812175
]

0 commit comments

Comments
 (0)