add validateAnnotations

This commit is contained in:
Jonathan Jenne 2023-11-06 13:20:03 +01:00
parent f4549c0481
commit a1bec774cd

View File

@ -217,6 +217,21 @@ class Annotation {
return await instance.delete(pageAnnotations);
}
public async validateAnnotations(instance: Instance): Promise<boolean> {
let pageAnnotations = (
await Promise.all(Array.from({ length: instance.totalPageCount }).map((_, pageIndex) =>
instance.getAnnotations(pageIndex)
))
).flatMap((annotations) =>
annotations.reduce((acc, annotation) => acc.concat(annotation), [])
).map((annotation: WidgetAnnotation) => {
console.log(annotation.toJS());
return annotation;
});
return true;
}
private createAnnotationFromElement(element: Element): [annotation: WidgetAnnotation, formField: SignatureFormFieldType] {
const id = PSPDFKit.generateInstantId()
const width = this.inchToPoint(element.width)