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:
parent
c84c23c4cb
commit
99b17a494d
3 changed files with 88 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue