Fix the default appearance of a Polygon annotation when a fill color is provided
It fixes #20062.
This commit is contained in:
parent
729f2bb148
commit
ecc7096a80
@ -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]];
|
||||
},
|
||||
});
|
||||
|
||||
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -731,3 +731,4 @@
|
||||
!bug1885505.pdf
|
||||
!bug1974436.pdf
|
||||
!firefox_logo.pdf
|
||||
!issue20062.pdf
|
||||
|
||||
BIN
test/pdfs/issue20062.pdf
Executable file
BIN
test/pdfs/issue20062.pdf
Executable file
Binary file not shown.
@ -12164,5 +12164,12 @@
|
||||
"rounds": 1,
|
||||
"type": "eq",
|
||||
"annotations": true
|
||||
},
|
||||
{
|
||||
"id": "issue20062",
|
||||
"file": "pdfs/issue20062.pdf",
|
||||
"md5": "9fa985242476c642464d94893528e40f",
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
}
|
||||
]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user