Implement support for stamp annotations
This commit is contained in:
parent
3be941d982
commit
400e4aae0e
@ -99,6 +99,9 @@ class AnnotationFactory {
|
|||||||
case 'StrikeOut':
|
case 'StrikeOut':
|
||||||
return new StrikeOutAnnotation(parameters);
|
return new StrikeOutAnnotation(parameters);
|
||||||
|
|
||||||
|
case 'Stamp':
|
||||||
|
return new StampAnnotation(parameters);
|
||||||
|
|
||||||
case 'FileAttachment':
|
case 'FileAttachment':
|
||||||
return new FileAttachmentAnnotation(parameters);
|
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 {
|
class FileAttachmentAnnotation extends Annotation {
|
||||||
constructor(parameters) {
|
constructor(parameters) {
|
||||||
super(parameters);
|
super(parameters);
|
||||||
|
@ -92,6 +92,9 @@ class AnnotationElementFactory {
|
|||||||
case AnnotationType.STRIKEOUT:
|
case AnnotationType.STRIKEOUT:
|
||||||
return new StrikeOutAnnotationElement(parameters);
|
return new StrikeOutAnnotationElement(parameters);
|
||||||
|
|
||||||
|
case AnnotationType.STAMP:
|
||||||
|
return new StampAnnotationElement(parameters);
|
||||||
|
|
||||||
case AnnotationType.FILEATTACHMENT:
|
case AnnotationType.FILEATTACHMENT:
|
||||||
return new FileAttachmentAnnotationElement(parameters);
|
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 {
|
class FileAttachmentAnnotationElement extends AnnotationElement {
|
||||||
constructor(parameters) {
|
constructor(parameters) {
|
||||||
super(parameters, /* isRenderable = */ true);
|
super(parameters, /* isRenderable = */ true);
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -285,6 +285,7 @@
|
|||||||
!annotation-highlight.pdf
|
!annotation-highlight.pdf
|
||||||
!annotation-line.pdf
|
!annotation-line.pdf
|
||||||
!annotation-square-circle.pdf
|
!annotation-square-circle.pdf
|
||||||
|
!annotation-stamp.pdf
|
||||||
!annotation-fileattachment.pdf
|
!annotation-fileattachment.pdf
|
||||||
!annotation-text-widget.pdf
|
!annotation-text-widget.pdf
|
||||||
!annotation-choice-widget.pdf
|
!annotation-choice-widget.pdf
|
||||||
|
BIN
test/pdfs/annotation-stamp.pdf
Normal file
BIN
test/pdfs/annotation-stamp.pdf
Normal file
Binary file not shown.
@ -3583,6 +3583,13 @@
|
|||||||
"type": "eq",
|
"type": "eq",
|
||||||
"annotations": true
|
"annotations": true
|
||||||
},
|
},
|
||||||
|
{ "id": "annotation-stamp",
|
||||||
|
"file": "pdfs/annotation-stamp.pdf",
|
||||||
|
"md5": "0a04d7ce1ad103cb3c033d26855d6ec7",
|
||||||
|
"rounds": 1,
|
||||||
|
"type": "eq",
|
||||||
|
"annotations": true
|
||||||
|
},
|
||||||
{ "id": "annotation-fileattachment",
|
{ "id": "annotation-fileattachment",
|
||||||
"file": "pdfs/annotation-fileattachment.pdf",
|
"file": "pdfs/annotation-fileattachment.pdf",
|
||||||
"md5": "d20ecee4b53c81b2dd44c8715a1b4a83",
|
"md5": "d20ecee4b53c81b2dd44c8715a1b4a83",
|
||||||
|
@ -191,6 +191,7 @@
|
|||||||
.annotationLayer .lineAnnotation svg line,
|
.annotationLayer .lineAnnotation svg line,
|
||||||
.annotationLayer .squareAnnotation svg rect,
|
.annotationLayer .squareAnnotation svg rect,
|
||||||
.annotationLayer .circleAnnotation svg ellipse,
|
.annotationLayer .circleAnnotation svg ellipse,
|
||||||
|
.annotationLayer .stampAnnotation,
|
||||||
.annotationLayer .fileAttachmentAnnotation {
|
.annotationLayer .fileAttachmentAnnotation {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user