Merge pull request #20063 from calixteman/issue20062

Fix the default appearance of a Polygon annotation when a fill color is provided
This commit is contained in:
calixteman 2025-07-08 22:10:52 +02:00 committed by GitHub
commit 481b74a1c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 29 additions and 1 deletions

View File

@ -4337,6 +4337,24 @@ class PolylineAnnotation extends MarkupAnnotation {
const strokeColor = this.color ? getPdfColorArray(this.color) : [0, 0, 0];
const strokeAlpha = dict.get("CA");
let fillColor = getRgbColor(dict.getArray("IC"), null);
if (fillColor) {
fillColor = getPdfColorArray(fillColor);
}
let operator;
if (fillColor) {
if (this.color) {
operator = fillColor.every((c, i) => c === strokeColor[i])
? "f"
: "B";
} else {
operator = "f";
}
} else {
operator = "S";
}
const borderWidth = this.borderStyle.width || 1,
borderAdjust = 2 * borderWidth;
@ -4361,13 +4379,15 @@ class PolylineAnnotation extends MarkupAnnotation {
extra: `${borderWidth} w`,
strokeColor,
strokeAlpha,
fillColor,
fillAlpha: fillColor ? strokeAlpha : null,
pointsCallback: (buffer, points) => {
for (let i = 0, ii = vertices.length; i < ii; i += 2) {
buffer.push(
`${vertices[i]} ${vertices[i + 1]} ${i === 0 ? "m" : "l"}`
);
}
buffer.push("S");
buffer.push(operator);
return [points[0], points[7], points[2], points[3]];
},
});

View File

@ -731,3 +731,4 @@
!bug1885505.pdf
!bug1974436.pdf
!firefox_logo.pdf
!issue20062.pdf

BIN
test/pdfs/issue20062.pdf Executable file

Binary file not shown.

View File

@ -12164,5 +12164,12 @@
"rounds": 1,
"type": "eq",
"annotations": true
},
{
"id": "issue20062",
"file": "pdfs/issue20062.pdf",
"md5": "9fa985242476c642464d94893528e40f",
"rounds": 1,
"type": "eq"
}
]