Refaktorisierte 'Annotation'-Funktionen zu statischen Methoden.

This commit is contained in:
Developer 02
2024-06-18 18:58:56 +02:00
parent c4a66ee5bb
commit 39cc257466
2 changed files with 15 additions and 16 deletions

View File

@@ -1,5 +1,5 @@
class Annotation {
createAnnotations(document) {
static createAnnotations(document) {
const annotations = []
document.elements.forEach((element) => {
@@ -11,7 +11,7 @@
return annotations
}
async getAnnotations(instance) {
static async getAnnotations(instance) {
const array = await Promise.all(
Array.from({ length: instance.totalPageCount }).map((_, pageIndex) =>
instance.getAnnotations(pageIndex)
@@ -23,14 +23,14 @@
)
}
async deleteAnnotations(instance) {
static async deleteAnnotations(instance) {
const allAnnotations = await this.getAnnotations(instance)
const pageAnnotations = allAnnotations.filter(this.isSignature)
//deleting all Annotations
return await instance.delete(pageAnnotations)
}
async validateAnnotations(instance) {
static async validateAnnotations(instance) {
const allAnnotations = await this.getAnnotations(instance)
const pageAnnotations = allAnnotations
.map((annotation) => {
@@ -40,11 +40,11 @@
return true
}
isSignature(annotation) {
static isSignature(annotation) {
return !!annotation.isSignature || annotation.description == 'FRAME'
}
createAnnotationFromElement(element) {
static createAnnotationFromElement(element) {
const id = PSPDFKit.generateInstantId()
const width = this.inchToPoint(element.width)
const height = this.inchToPoint(element.height)
@@ -68,7 +68,7 @@
return [annotation, formField]
}
createSignatureAnnotation(id, width, height, top, left, pageIndex) {
static createSignatureAnnotation(id, width, height, top, left, pageIndex) {
const annotation = new PSPDFKit.Annotations.WidgetAnnotation({
id: id,
pageIndex: pageIndex,
@@ -86,7 +86,7 @@
return annotation
}
createImageAnnotation(boundingBox, pageIndex, imageAttachmentId) {
static createImageAnnotation(boundingBox, pageIndex, imageAttachmentId) {
const frameAnnotation = new PSPDFKit.Annotations.ImageAnnotation({
pageIndex: pageIndex,
isSignature: false,
@@ -101,7 +101,7 @@
return frameAnnotation
}
async createAnnotationFrameBlob(receiverName, receiverSignature, timestamp, width, height) {
static async createAnnotationFrameBlob(receiverName, receiverSignature, timestamp, width, height) {
const canvas = document.createElement('canvas')
const scale = 4
const fontSize = 10
@@ -154,7 +154,7 @@
})
}
inchToPoint(inch) {
static inchToPoint(inch) {
return inch * 72
}
}