I saved the corresponding fields, that have to be locked in the Variable _fieldsToLockTemp and when saving the document is set these fields to locked.
Now in Version 8.2.0 there is no getDigitalSignatureField(name: string) function. I found the getDigitalSignatureFieldIterator(), but i haven’t found a way yet, how to test if the DigtalsignatureField returned by the Iterator belongs to the SignatureWidgetAnnotation returned by AnnotationCreateSignature.locationSelected.
thank you for your answer. I saw, that i forgot to call PDFNet.initialize().
I already found out how to iterate through the digital signature fields. My problem was how to get the connection between the SignatureWidgetAnnotation that is returned by AnnotationCreateSignature.locationSelected and the field, that was clicked onto.
I ended up, doing it as follows, although i’m not really sure if it’s the right way to do, but it works for now:
this.webviewer.instance.Core.PDFNet.runWithCleanup(async () => {
await this.webviewer.instance.Core.PDFNet.initialize();
// Tool holen
const tool = this.webviewer.instance.Core.documentViewer.getTool('AnnotationCreateSignature');
// Sobald auf ein Unterschriften-Feld geklickt wurde
// -> die Felder ermitteln, die gesperrt werden sollen
tool.addEventListener('locationSelected', async (_, signatureWidget) => {
const doc = await this.webviewer.instance.Core.documentViewer.getDocument().getPDFDoc();
const iterator = await doc.getDigitalSignatureFieldIteratorBegin();
for (; await iterator.hasNext(); await iterator.next()) {
const field = await iterator.current();
const sdfObj = await field.getSDFObj();
const itr = await sdfObj.find('T');
if (itr && await itr.hasNext()) {
const name = await (await itr.value()).getAsPDFText();
if (name === signatureWidget.fieldName) {
this._fieldsToLockTemp = await field.getLockedFields();
break;
}
}
}
});
},
this.webviewer.lizenz);