mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Add support of Ink annotation
This commit is contained in:
parent
1cfb723dd4
commit
b5806735d8
7 changed files with 173 additions and 1 deletions
|
@ -106,6 +106,9 @@ class AnnotationFactory {
|
|||
case 'Polygon':
|
||||
return new PolygonAnnotation(parameters);
|
||||
|
||||
case 'Ink':
|
||||
return new InkAnnotation(parameters);
|
||||
|
||||
case 'Highlight':
|
||||
return new HighlightAnnotation(parameters);
|
||||
|
||||
|
@ -1013,6 +1016,34 @@ class PolygonAnnotation extends PolylineAnnotation {
|
|||
}
|
||||
}
|
||||
|
||||
class InkAnnotation extends Annotation {
|
||||
constructor(parameters) {
|
||||
super(parameters);
|
||||
|
||||
this.data.annotationType = AnnotationType.INK;
|
||||
|
||||
let dict = parameters.dict;
|
||||
const xref = parameters.xref;
|
||||
|
||||
let originalInkLists = dict.getArray('InkList');
|
||||
this.data.inkLists = [];
|
||||
for (let i = 0, ii = originalInkLists.length; i < ii; ++i) {
|
||||
// The raw ink lists array contains arrays 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.
|
||||
this.data.inkLists.push([]);
|
||||
for (let j = 0, jj = originalInkLists[i].length; j < jj; j += 2) {
|
||||
this.data.inkLists[i].push({
|
||||
x: xref.fetchIfRef(originalInkLists[i][j]),
|
||||
y: xref.fetchIfRef(originalInkLists[i][j + 1]),
|
||||
});
|
||||
}
|
||||
}
|
||||
this._preparePopup(dict);
|
||||
}
|
||||
}
|
||||
|
||||
class HighlightAnnotation extends Annotation {
|
||||
constructor(parameters) {
|
||||
super(parameters);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue