diff --git a/src/core/annotation.js b/src/core/annotation.js index 89e39ceeb..d3aa434ea 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -99,6 +99,9 @@ class AnnotationFactory { case 'StrikeOut': return new StrikeOutAnnotation(parameters); + case 'Stamp': + return new StampAnnotation(parameters); + case 'FileAttachment': return new FileAttachmentAnnotation(parameters); @@ -946,6 +949,15 @@ class StrikeOutAnnotation extends Annotation { } } +class StampAnnotation extends Annotation { + constructor(parameters) { + super(parameters); + + this.data.annotationType = AnnotationType.STAMP; + this._preparePopup(parameters.dict); + } +} + class FileAttachmentAnnotation extends Annotation { constructor(parameters) { super(parameters); diff --git a/src/display/annotation_layer.js b/src/display/annotation_layer.js index 250c5b59c..de9048da5 100644 --- a/src/display/annotation_layer.js +++ b/src/display/annotation_layer.js @@ -92,6 +92,9 @@ class AnnotationElementFactory { case AnnotationType.STRIKEOUT: return new StrikeOutAnnotationElement(parameters); + case AnnotationType.STAMP: + return new StampAnnotationElement(parameters); + case AnnotationType.FILEATTACHMENT: return new FileAttachmentAnnotationElement(parameters); @@ -1004,6 +1007,30 @@ class StrikeOutAnnotationElement extends AnnotationElement { } } +class StampAnnotationElement extends AnnotationElement { + constructor(parameters) { + let isRenderable = !!(parameters.data.hasPopup || + parameters.data.title || parameters.data.contents); + super(parameters, isRenderable, /* ignoreBorder = */ true); + } + + /** + * Render the stamp annotation's HTML element in the empty container. + * + * @public + * @memberof StampAnnotationElement + * @returns {HTMLSectionElement} + */ + render() { + this.container.className = 'stampAnnotation'; + + if (!this.data.hasPopup) { + this._createPopup(this.container, null, this.data); + } + return this.container; + } +} + class FileAttachmentAnnotationElement extends AnnotationElement { constructor(parameters) { super(parameters, /* isRenderable = */ true); diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 56fb6c713..f4d0713ad 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -285,6 +285,7 @@ !annotation-highlight.pdf !annotation-line.pdf !annotation-square-circle.pdf +!annotation-stamp.pdf !annotation-fileattachment.pdf !annotation-text-widget.pdf !annotation-choice-widget.pdf diff --git a/test/pdfs/annotation-stamp.pdf b/test/pdfs/annotation-stamp.pdf new file mode 100644 index 000000000..625ae3ac6 Binary files /dev/null and b/test/pdfs/annotation-stamp.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 8f402412e..0882f4670 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -3583,6 +3583,13 @@ "type": "eq", "annotations": true }, + { "id": "annotation-stamp", + "file": "pdfs/annotation-stamp.pdf", + "md5": "0a04d7ce1ad103cb3c033d26855d6ec7", + "rounds": 1, + "type": "eq", + "annotations": true + }, { "id": "annotation-fileattachment", "file": "pdfs/annotation-fileattachment.pdf", "md5": "d20ecee4b53c81b2dd44c8715a1b4a83", diff --git a/web/annotation_layer_builder.css b/web/annotation_layer_builder.css index d9e3d8e0d..a12048ce6 100644 --- a/web/annotation_layer_builder.css +++ b/web/annotation_layer_builder.css @@ -191,6 +191,7 @@ .annotationLayer .lineAnnotation svg line, .annotationLayer .squareAnnotation svg rect, .annotationLayer .circleAnnotation svg ellipse, +.annotationLayer .stampAnnotation, .annotationLayer .fileAttachmentAnnotation { cursor: pointer; }