Browse Source

Merge pull request #6813 from timvandermeij/underline-annotation

Implement support for Underline annotations
Jonas Jenwald 9 years ago
parent
commit
b32cdf5836
  1. 19
      src/core/annotation.js
  2. 30
      src/display/annotation_layer.js
  3. 1
      test/pdfs/.gitignore
  4. BIN
      test/pdfs/annotation-underline.pdf
  5. 7
      test/test_manifest.json
  6. 4
      web/annotation_layer_builder.css

19
src/core/annotation.js

@ -96,6 +96,9 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ { @@ -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() { @@ -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;

30
src/display/annotation_layer.js

@ -72,6 +72,9 @@ AnnotationElementFactory.prototype = @@ -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() { @@ -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

1
test/pdfs/.gitignore vendored

@ -201,3 +201,4 @@ @@ -201,3 +201,4 @@
!openoffice.pdf
!annotation-link-text-popup.pdf
!annotation-text-without-popup.pdf
!annotation-underline.pdf

BIN
test/pdfs/annotation-underline.pdf

Binary file not shown.

7
test/test_manifest.json

@ -2638,6 +2638,13 @@ @@ -2638,6 +2638,13 @@
"annotations": true,
"about": "Text annotation without a separate Popup annotation"
},
{ "id": "annotation-underline",
"file": "pdfs/annotation-underline.pdf",
"md5": "c24b3aba771de52f9bac25e854c39458",
"rounds": 1,
"type": "eq",
"annotations": true
},
{ "id": "issue6108",
"file": "pdfs/issue6108.pdf",
"md5": "8961cb55149495989a80bf0487e0f076",

4
web/annotation_layer_builder.css

@ -68,3 +68,7 @@ @@ -68,3 +68,7 @@
.annotationLayer .popup p {
padding-top: 0.2em;
}
.annotationLayer .underlineAnnotation {
cursor: pointer;
}

Loading…
Cancel
Save