1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Implement support for polyline annotations

This commit is contained in:
Tim van der Meij 2017-09-17 20:18:22 +02:00
parent c84c23c4cb
commit 99b17a494d
No known key found for this signature in database
GPG key ID: 8C3FD2925A5F2762
3 changed files with 88 additions and 1 deletions

View file

@ -87,6 +87,9 @@ class AnnotationFactory {
case 'Circle':
return new CircleAnnotation(parameters);
case 'PolyLine':
return new PolylineAnnotation(parameters);
case 'Highlight':
return new HighlightAnnotation(parameters);
@ -913,6 +916,30 @@ class CircleAnnotation extends Annotation {
}
}
class PolylineAnnotation extends Annotation {
constructor(parameters) {
super(parameters);
this.data.annotationType = AnnotationType.POLYLINE;
// The vertices array is an array of numbers representing the alternating
// horizontal and vertical coordinates, respectively, of each vertex.
// Convert this to an array of objects with x and y coordinates.
let dict = parameters.dict;
let rawVertices = dict.getArray('Vertices');
this.data.vertices = [];
for (let i = 0, ii = rawVertices.length; i < ii; i += 2) {
this.data.vertices.push({
x: rawVertices[i],
y: rawVertices[i + 1],
});
}
this._preparePopup(dict);
}
}
class HighlightAnnotation extends Annotation {
constructor(parameters) {
super(parameters);