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:
parent
d6e0b2d92e
commit
5828ff6cb0
4 changed files with 36 additions and 3 deletions
|
@ -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,
|
||||
];
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue