mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
Annotations: implement support for line annotations
This patch implements support for line annotations. Other viewers only show the popup annotation when hovering over the line, which may have any orientation. To make this possible, we render an invisible line (SVG element) over the line on the canvas that acts as the trigger for the popup annotation. This invisible line has the same starting coordinates, ending coordinates and width of the line on the canvas.
This commit is contained in:
parent
30d63b0c50
commit
e15a2ec523
7 changed files with 125 additions and 0 deletions
|
@ -115,6 +115,9 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
|
|||
case 'Popup':
|
||||
return new PopupAnnotation(parameters);
|
||||
|
||||
case 'Line':
|
||||
return new LineAnnotation(parameters);
|
||||
|
||||
case 'Highlight':
|
||||
return new HighlightAnnotation(parameters);
|
||||
|
||||
|
@ -955,6 +958,8 @@ var PopupAnnotation = (function PopupAnnotationClosure() {
|
|||
return;
|
||||
}
|
||||
|
||||
var parentSubtype = parentItem.get('Subtype');
|
||||
this.data.parentType = isName(parentSubtype) ? parentSubtype.name : null;
|
||||
this.data.parentId = dict.getRaw('Parent').toString();
|
||||
this.data.title = stringToPDFString(parentItem.get('T') || '');
|
||||
this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
|
||||
|
@ -983,6 +988,22 @@ var PopupAnnotation = (function PopupAnnotationClosure() {
|
|||
return PopupAnnotation;
|
||||
})();
|
||||
|
||||
var LineAnnotation = (function LineAnnotationClosure() {
|
||||
function LineAnnotation(parameters) {
|
||||
Annotation.call(this, parameters);
|
||||
|
||||
this.data.annotationType = AnnotationType.LINE;
|
||||
|
||||
var dict = parameters.dict;
|
||||
this.data.lineCoordinates = Util.normalizeRect(dict.getArray('L'));
|
||||
this._preparePopup(dict);
|
||||
}
|
||||
|
||||
Util.inherit(LineAnnotation, Annotation, {});
|
||||
|
||||
return LineAnnotation;
|
||||
})();
|
||||
|
||||
var HighlightAnnotation = (function HighlightAnnotationClosure() {
|
||||
function HighlightAnnotation(parameters) {
|
||||
Annotation.call(this, parameters);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue