Implement free text annotations
This commit is contained in:
parent
62dc431af6
commit
ae2a4dc3dd
@ -92,6 +92,9 @@ class AnnotationFactory {
|
|||||||
case 'Popup':
|
case 'Popup':
|
||||||
return new PopupAnnotation(parameters);
|
return new PopupAnnotation(parameters);
|
||||||
|
|
||||||
|
case 'FreeText':
|
||||||
|
return new FreeTextAnnotation(parameters);
|
||||||
|
|
||||||
case 'Line':
|
case 'Line':
|
||||||
return new LineAnnotation(parameters);
|
return new LineAnnotation(parameters);
|
||||||
|
|
||||||
@ -964,6 +967,14 @@ class PopupAnnotation extends Annotation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class FreeTextAnnotation extends MarkupAnnotation {
|
||||||
|
constructor(parameters) {
|
||||||
|
super(parameters);
|
||||||
|
|
||||||
|
this.data.annotationType = AnnotationType.FREETEXT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class LineAnnotation extends MarkupAnnotation {
|
class LineAnnotation extends MarkupAnnotation {
|
||||||
constructor(parameters) {
|
constructor(parameters) {
|
||||||
super(parameters);
|
super(parameters);
|
||||||
|
@ -71,6 +71,9 @@ class AnnotationElementFactory {
|
|||||||
case AnnotationType.POPUP:
|
case AnnotationType.POPUP:
|
||||||
return new PopupAnnotationElement(parameters);
|
return new PopupAnnotationElement(parameters);
|
||||||
|
|
||||||
|
case AnnotationType.FREETEXT:
|
||||||
|
return new FreeTextAnnotationElement(parameters);
|
||||||
|
|
||||||
case AnnotationType.LINE:
|
case AnnotationType.LINE:
|
||||||
return new LineAnnotationElement(parameters);
|
return new LineAnnotationElement(parameters);
|
||||||
|
|
||||||
@ -807,6 +810,30 @@ class PopupElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class FreeTextAnnotationElement extends AnnotationElement {
|
||||||
|
constructor(parameters) {
|
||||||
|
const isRenderable = !!(parameters.data.hasPopup ||
|
||||||
|
parameters.data.title || parameters.data.contents);
|
||||||
|
super(parameters, isRenderable, /* ignoreBorder = */ true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the free text annotation's HTML element in the empty container.
|
||||||
|
*
|
||||||
|
* @public
|
||||||
|
* @memberof FreeTextAnnotationElement
|
||||||
|
* @returns {HTMLSectionElement}
|
||||||
|
*/
|
||||||
|
render() {
|
||||||
|
this.container.className = 'freeTextAnnotation';
|
||||||
|
|
||||||
|
if (!this.data.hasPopup) {
|
||||||
|
this._createPopup(this.container, null, this.data);
|
||||||
|
}
|
||||||
|
return this.container;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class LineAnnotationElement extends AnnotationElement {
|
class LineAnnotationElement extends AnnotationElement {
|
||||||
constructor(parameters) {
|
constructor(parameters) {
|
||||||
let isRenderable = !!(parameters.data.hasPopup ||
|
let isRenderable = !!(parameters.data.hasPopup ||
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -323,6 +323,7 @@
|
|||||||
!annotation-strikeout.pdf
|
!annotation-strikeout.pdf
|
||||||
!annotation-squiggly.pdf
|
!annotation-squiggly.pdf
|
||||||
!annotation-highlight.pdf
|
!annotation-highlight.pdf
|
||||||
|
!annotation-freetext.pdf
|
||||||
!annotation-line.pdf
|
!annotation-line.pdf
|
||||||
!annotation-square-circle.pdf
|
!annotation-square-circle.pdf
|
||||||
!annotation-stamp.pdf
|
!annotation-stamp.pdf
|
||||||
|
BIN
test/pdfs/annotation-freetext.pdf
Executable file
BIN
test/pdfs/annotation-freetext.pdf
Executable file
Binary file not shown.
@ -4007,6 +4007,13 @@
|
|||||||
"type": "eq",
|
"type": "eq",
|
||||||
"annotations": true
|
"annotations": true
|
||||||
},
|
},
|
||||||
|
{ "id": "annotation-freetext",
|
||||||
|
"file": "pdfs/annotation-freetext.pdf",
|
||||||
|
"md5": "6ca19ce632ead3aed08f22e588510e2f",
|
||||||
|
"rounds": 1,
|
||||||
|
"type": "eq",
|
||||||
|
"annotations": true
|
||||||
|
},
|
||||||
{ "id": "annotation-line",
|
{ "id": "annotation-line",
|
||||||
"file": "pdfs/annotation-line.pdf",
|
"file": "pdfs/annotation-line.pdf",
|
||||||
"md5": "fde60608be2748f10fb6522cba425ca1",
|
"md5": "fde60608be2748f10fb6522cba425ca1",
|
||||||
|
@ -183,6 +183,7 @@
|
|||||||
.annotationLayer .underlineAnnotation,
|
.annotationLayer .underlineAnnotation,
|
||||||
.annotationLayer .squigglyAnnotation,
|
.annotationLayer .squigglyAnnotation,
|
||||||
.annotationLayer .strikeoutAnnotation,
|
.annotationLayer .strikeoutAnnotation,
|
||||||
|
.annotationLayer .freeTextAnnotation,
|
||||||
.annotationLayer .lineAnnotation svg line,
|
.annotationLayer .lineAnnotation svg line,
|
||||||
.annotationLayer .squareAnnotation svg rect,
|
.annotationLayer .squareAnnotation svg rect,
|
||||||
.annotationLayer .circleAnnotation svg ellipse,
|
.annotationLayer .circleAnnotation svg ellipse,
|
||||||
|
Loading…
Reference in New Issue
Block a user