Implement rendering polyline/polygon annotations without appearance stream

This commit is contained in:
Tim van der Meij 2021-04-27 19:02:20 +02:00
parent ca668587c6
commit 60ab15427f
No known key found for this signature in database
GPG Key ID: 8C3FD2925A5F2762
4 changed files with 33 additions and 0 deletions

View File

@ -2507,6 +2507,31 @@ class PolylineAnnotation extends MarkupAnnotation {
y: rawVertices[i + 1],
});
}
if (!this.appearance) {
// The default stroke color is black.
const strokeColor = this.color
? Array.from(this.color).map(c => c / 255)
: [0, 0, 0];
const borderWidth = this.borderStyle.width || 1;
this._setDefaultAppearance({
xref: parameters.xref,
extra: `${borderWidth} w`,
strokeColor,
pointsCallback: (buffer, points) => {
const vertices = this.data.vertices;
for (let i = 0, ii = vertices.length; i < ii; i++) {
buffer.push(
`${vertices[i].x} ${vertices[i].y} ${i === 0 ? "m" : "l"}`
);
}
buffer.push("S");
return [points[0].x, points[1].x, points[3].y, points[1].y];
},
});
}
}
}

View File

@ -412,6 +412,7 @@
!annotation-choice-widget.pdf
!annotation-button-widget.pdf
!annotation-polyline-polygon.pdf
!annotation-polyline-polygon-without-appearance.pdf
!zero_descent.pdf
!operator-in-TJ-array.pdf
!issue7878.pdf

View File

@ -4989,6 +4989,13 @@
"type": "eq",
"annotations": true
},
{ "id": "annotation-polyline-polygon-without-appearance",
"file": "pdfs/annotation-polyline-polygon-without-appearance.pdf",
"md5": "b776937148e9f7c4de6bea552e23b92f",
"rounds": 1,
"annotations": true,
"type": "eq"
},
{ "id": "issue4872",
"file": "pdfs/issue4872.pdf",
"md5": "21c6cbc682140d6f6017bbeb45892053",