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

Merge pull request #13305 from timvandermeij/annotation-polygon-polyline-no-appearance-stream

Implement rendering polyline/polygon annotations without appearance stream
This commit is contained in:
Tim van der Meij 2021-04-27 20:03:35 +02:00 committed by GitHub
commit 0acd801b1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 0 deletions

View file

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