Entwicklung von Methoden zur Datums- und Ortserkennung. Fügen Sie "annotations" hinzu, damit der Benutzer das Datum und die Ortsangaben bei Bedarf aktualisieren kann.
This commit is contained in:
@@ -1,25 +1,27 @@
|
||||
class Annotation {
|
||||
static createAnnotations(document) {
|
||||
static async createAnnotations(document) {
|
||||
const signatures = []
|
||||
document.elements.forEach((element) => {
|
||||
const [annotation, formField] = Annotation.createSignature(element)
|
||||
|
||||
for(var element of document.elements){
|
||||
const [annotation, formField, annotation2, formFieldDate] = await Annotation.createSignature(element)
|
||||
signatures.push(annotation)
|
||||
signatures.push(formField)
|
||||
})
|
||||
|
||||
return {
|
||||
signatures: signatures
|
||||
signatures.push(annotation2)
|
||||
signatures.push(formFieldDate)
|
||||
}
|
||||
|
||||
return [...signatures ]
|
||||
}
|
||||
|
||||
static createSignature(element) {
|
||||
static async 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
|
||||
console.log(id)
|
||||
|
||||
//signatures
|
||||
const annotation = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||
id: id,
|
||||
pageIndex: page,
|
||||
@@ -39,7 +41,31 @@
|
||||
annotationIds: PSPDFKit.Immutable.List([annotation.id]),
|
||||
})
|
||||
|
||||
return [annotation, formField]
|
||||
//date
|
||||
var city = await getCity();
|
||||
const id_date = PSPDFKit.generateInstantId()
|
||||
const annotation_date = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||
id: id_date,
|
||||
pageIndex: page,
|
||||
formFieldName: id_date,
|
||||
backgroundColor: PSPDFKit.Color.DarkBlue,
|
||||
blendMode: 'multiply',
|
||||
boundingBox: new PSPDFKit.Geometry.Rect({
|
||||
width: width * 1.5,
|
||||
height: height / 2,
|
||||
top: top + height + 10,
|
||||
left: left - width * .25,
|
||||
}),
|
||||
fontSize:8
|
||||
})
|
||||
|
||||
const formFieldDate = new PSPDFKit.FormFields.TextFormField({
|
||||
name: id_date,
|
||||
annotationIds: PSPDFKit.Immutable.List([annotation_date.id]),
|
||||
value: getLocaleDateString() + ", " + city
|
||||
})
|
||||
|
||||
return [annotation, formField, annotation_date, formFieldDate]
|
||||
}
|
||||
|
||||
static createTextBox(element) {
|
||||
|
||||
Reference in New Issue
Block a user