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 #6813 from timvandermeij/underline-annotation

Implement support for Underline annotations
This commit is contained in:
Jonas Jenwald 2015-12-28 23:48:31 +01:00
commit b32cdf5836
6 changed files with 61 additions and 0 deletions

View file

@ -96,6 +96,9 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
case 'Popup':
return new PopupAnnotation(parameters);
case 'Underline':
return new UnderlineAnnotation(parameters);
default:
warn('Unimplemented annotation type "' + subtype + '", ' +
'falling back to base annotation');
@ -786,6 +789,22 @@ var PopupAnnotation = (function PopupAnnotationClosure() {
return PopupAnnotation;
})();
var UnderlineAnnotation = (function UnderlineAnnotationClosure() {
function UnderlineAnnotation(parameters) {
Annotation.call(this, parameters);
this.data.annotationType = AnnotationType.UNDERLINE;
this.data.hasHtml = true;
// PDF viewers completely ignore any border styles.
this.data.borderStyle.setWidth(0);
}
Util.inherit(UnderlineAnnotation, Annotation, {});
return UnderlineAnnotation;
})();
exports.Annotation = Annotation;
exports.AnnotationBorderStyle = AnnotationBorderStyle;
exports.AnnotationFactory = AnnotationFactory;

View file

@ -72,6 +72,9 @@ AnnotationElementFactory.prototype =
case AnnotationType.POPUP:
return new PopupAnnotationElement(parameters);
case AnnotationType.UNDERLINE:
return new UnderlineAnnotationElement(parameters);
default:
throw new Error('Unimplemented annotation type "' + subtype + '"');
}
@ -600,6 +603,33 @@ var PopupElement = (function PopupElementClosure() {
return PopupElement;
})();
/**
* @class
* @alias UnderlineAnnotationElement
*/
var UnderlineAnnotationElement = (
function UnderlineAnnotationElementClosure() {
function UnderlineAnnotationElement(parameters) {
AnnotationElement.call(this, parameters);
}
Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
/**
* Render the underline annotation's HTML element in the empty container.
*
* @public
* @memberof UnderlineAnnotationElement
* @returns {HTMLSectionElement}
*/
render: function UnderlineAnnotationElement_render() {
this.container.className = 'underlineAnnotation';
return this.container;
}
});
return UnderlineAnnotationElement;
})();
/**
* @typedef {Object} AnnotationLayerParameters
* @property {PageViewport} viewport