diff --git a/src/core/annotation.js b/src/core/annotation.js index f632ea108..be87b6c9b 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -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]; + }, + }); + } } } diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 2c4badc68..d3498e1c5 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -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 diff --git a/test/pdfs/annotation-polyline-polygon-without-appearance.pdf b/test/pdfs/annotation-polyline-polygon-without-appearance.pdf new file mode 100644 index 000000000..2dc953768 Binary files /dev/null and b/test/pdfs/annotation-polyline-polygon-without-appearance.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 6da2d90ee..61f33ff4d 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -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",