1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

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