eine separate createTextBox-Methode wurde als Teil des Signaturprozesses geschrieben, um die Stadt und das Datum zu schreiben

This commit is contained in:
Developer 02 2024-06-18 21:27:52 +02:00
parent 2f4ffac9c4
commit 9e019c0b69
2 changed files with 78 additions and 36 deletions

View File

@ -1,16 +1,87 @@
class Annotation {
static createAnnotations(document) {
const annotations = []
const signatures = []
document.elements.forEach((element) => {
const [annotation, formField] = Annotation.createAnnotationFromElement(element)
annotations.push(annotation)
annotations.push(formField)
const [annotation, formField] = Annotation.createSignature(element)
signatures.push(annotation)
signatures.push(formField)
})
return annotations
document.elements.forEach((element) => {
const [annotation, formField] = Annotation.createSignature(element)
signatures.push(annotation)
signatures.push(formField)
})
return {
signatures: signatures
}
}
static createSignature(element) {
const id = PSPDFKit.generateInstantId()
const width = Annotation.inchToPoint(element.width)
const height = Annotation.inchToPoint(element.height)
const top = Annotation.inchToPoint(element.top) - height / 2
const left = Annotation.inchToPoint(element.left) - width / 2
const page = element.page - 1
const annotation = new PSPDFKit.Annotations.WidgetAnnotation({
id: id,
pageIndex: page,
formFieldName: id,
backgroundColor: PSPDFKit.Color.YELLOW,
blendMode: 'multiply',
boundingBox: new PSPDFKit.Geometry.Rect({
width,
height,
top,
left,
}),
})
const formField = new PSPDFKit.FormFields.SignatureFormField({
name: id,
annotationIds: PSPDFKit.Immutable.List([annotation.id]),
})
return [annotation, formField]
}
static createTextBox(element) {
const id = PSPDFKit.generateInstantId()
const width = Annotation.inchToPoint(element.width)
const height = Annotation.inchToPoint(element.height)
const top = Annotation.inchToPoint(element.top) - height / 2
const left = Annotation.inchToPoint(element.left) - width / 2
const page = element.page - 1
//shift
top += height + 10
const annotation = new PSPDFKit.Annotations.WidgetAnnotation({
id: id,
pageIndex: page,
formFieldName: id,
backgroundColor: PSPDFKit.Color.YELLOW,
blendMode: 'multiply',
boundingBox: new PSPDFKit.Geometry.Rect({
width,
height,
top,
left,
}),
})
const formField = new PSPDFKit.FormFields.SignatureFormField({
name: id,
annotationIds: PSPDFKit.Immutable.List([annotation.id]),
})
return [annotation, formField]
}
static createText
static async getAnnotations(instance) {
const array = await Promise.all(
Array.from({ length: instance.totalPageCount }).map((_, pageIndex) =>
@ -44,35 +115,6 @@
return !!annotation.isSignature || annotation.description == 'FRAME'
}
static createAnnotationFromElement(element) {
const id = PSPDFKit.generateInstantId()
const width = Annotation.inchToPoint(element.width)
const height = Annotation.inchToPoint(element.height)
const top = Annotation.inchToPoint(element.top) - height / 2
const left = Annotation.inchToPoint(element.left) - width / 2
const page = element.page - 1
const annotation = new PSPDFKit.Annotations.WidgetAnnotation({
id: id,
pageIndex: page,
formFieldName: id,
backgroundColor: PSPDFKit.Color.YELLOW,
blendMode: 'multiply',
boundingBox: new PSPDFKit.Geometry.Rect({
width,
height,
top,
left,
}),
})
const formField = new PSPDFKit.FormFields.SignatureFormField({
name: id,
annotationIds: PSPDFKit.Immutable.List([annotation.id]),
})
return [annotation, formField]
}
static createImageAnnotation(boundingBox, pageIndex, imageAttachmentId) {
const frameAnnotation = new PSPDFKit.Annotations.ImageAnnotation({
pageIndex: pageIndex,

View File

@ -71,7 +71,7 @@ class App {
try {
this.signatureCount = this.currentDocument.elements.length
const annotations = Annotation.createAnnotations(this.currentDocument)
await this.Instance.create(annotations)
await this.Instance.create(annotations.signatures)
const openResponse = await this.Network.openDocument(this.envelopeKey)