diff --git a/src/core/annotation.js b/src/core/annotation.js index 02dc2c273..e28d12b82 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -2280,9 +2280,34 @@ class LineAnnotation extends MarkupAnnotation { this.data.annotationType = AnnotationType.LINE; - this.data.lineCoordinates = Util.normalizeRect( - parameters.dict.getArray("L") - ); + const lineCoordinates = parameters.dict.getArray("L"); + this.data.lineCoordinates = Util.normalizeRect(lineCoordinates); + + 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; + + this._setDefaultAppearance({ + xref: parameters.xref, + extra: `${borderWidth} w`, + strokeColor, + pointsCallback: (buffer, points) => { + buffer.push(`${lineCoordinates[0]} ${lineCoordinates[1]} m`); + buffer.push(`${lineCoordinates[2]} ${lineCoordinates[3]} l`); + buffer.push("S"); + return [ + points[0].x - borderWidth, + points[1].x + borderWidth, + points[3].y - borderWidth, + points[1].y + borderWidth, + ]; + }, + }); + } } } diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 324651782..42e7bfeff 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -393,6 +393,7 @@ !issue12418_reduced.pdf !annotation-freetext.pdf !annotation-line.pdf +!annotation-line-without-appearance.pdf !bug1669099.pdf !annotation-square-circle.pdf !annotation-square-circle-without-appearance.pdf diff --git a/test/pdfs/annotation-line-without-appearance.pdf b/test/pdfs/annotation-line-without-appearance.pdf new file mode 100644 index 000000000..b85b75671 Binary files /dev/null and b/test/pdfs/annotation-line-without-appearance.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index c8b7f3497..1a4422364 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -4717,6 +4717,13 @@ "type": "eq", "annotations": true }, + { "id": "annotation-line-without-appearance", + "file": "pdfs/annotation-line-without-appearance.pdf", + "md5": "1f60935b2a7719ce40616af60fc308a2", + "rounds": 1, + "annotations": true, + "type": "eq" + }, { "id": "annotation-square-circle", "file": "pdfs/annotation-square-circle.pdf", "md5": "cfd3c302f68d61e1d55ed9c7896046c3",