Implement rendering line annotations without appearance stream

This commit is contained in:
Tim van der Meij 2021-02-28 18:51:37 +01:00
parent d6e0b2d92e
commit 5828ff6cb0
No known key found for this signature in database
GPG Key ID: 8C3FD2925A5F2762
4 changed files with 36 additions and 3 deletions

View File

@ -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,
];
},
});
}
}
}

View File

@ -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

Binary file not shown.

View File

@ -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",