getDigitalSignatureField with WebViewer v8.2.0


i used WebViewer Version 7.3.3 and now migrating to Version 8.2.0. I’m using the FullAPI.

When creating a PDF-Formular, there is an Option, to lock all formfields, when signing a digtal signature field:

If i’m right, i have to implement this functionality myself in the WebViewer. With Version 7.3.3 i did it this way:

this.webviewer.instance.Core.PDFNet.runWithCleanup(() => {
    // Tool holen
    const tool = this.webviewer.instance.Core.documentViewer.getTool('AnnotationCreateSignature');

    tool.addEventListener('locationSelected', async (_, signatureWidget) => {
      if (signatureWidget instanceof this.webviewer.instance.Core.Annotations.SignatureWidgetAnnotation) {
        .then(doc => doc.getDigitalSignatureField(signatureWidget.fieldName))
        .then(sig => sig.getLockedFields())
        .then(lockedFields => this._fieldsToLockTemp = lockedFields);

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.



Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:


Hello there.

With the new iterator, you can do something like this to get the locked fields:

const { PDFNet, documentViewer, annotationManager, Annotations } = instance.Core;

  documentViewer.addEventListener('annotationsLoaded', async () => {
    await PDFNet.initialize();

    const document = await documentViewer.getDocument().getPDFDoc();

    const iterator = await document.getDigitalSignatureFieldIteratorBegin();

    for (; await iterator.hasNext(); await {
      const signatureField = await iterator.current();
      const lockedFields = await signatureField.getLockedFields();
      // ...

Let me know if this works for you and if you have any further questions.

Hello Felix,

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 {
        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();

Hello Chris.

Yes, this looks like a reasonable solution.

1 Like