Two signatures are showing

Below is my Document Template.

On clicking to sign here, i have created sign, see below.

then i moved the signature to other place and just saved the template. see below

after that i have reopen the document template, showing sign here button and signature which i have signed. see below.

is this natural behavior of system or we can do something about this.

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:

Guides:APIs:Forums:

I’ve seen this before and I think it’s a natural behavior of the system.

Folks from PDFTron can provide a more accurate answer, but I think the reason for this behavior is that the signature you see here is in fact a freehand annotation, not a digital signature. It’s not in PDF spec that a freehand annotation can be tied to a signature widget, which means the relationship between a freehand annotation and a signature widget will be lost after the document is reopened. If you move the signature annotation WebViewer doesn’t have a way(not sure if this is true) to know they are linked anymore, and thinks the widget isn’t signed, thus showing the Sign here button.

If you don’t want this to happen I think a workaround is to lock the signature annotation as soon as it’s getting signed, so it can’t be moved, and the Sign here button won’t show when you reload the document.

I know that custom data is persisted after reopening the document, so I’m not sure if you can set the custom data on the widget to let it know that it has a signature associated with it, and then implement extra logic on your end to not show the button.

2 Likes

Hello,

Just to give some background on how this works. WebViewer only knows which signature is tied to which field (widget) through the position. When the signature is created from signing that field, it is created with the same coordinates. When the document is reloaded, WebViewer is expecting that to be in the same position and it will link the two together again.

However, since you have moved the signature away, WebViewer can no longer link the two and you got the result you saw.

You can link them manually though but you will have to determine which freehand annotations are tied to which fields. The best way would probably be to use setCustomData to store the associated IDs and link them together when they are imported:

    annotManager.addEventListener('annotationChanged', (annotations, action, info) => {
      // Perform this when annotation is added
      if (action === 'add') {
        annotations.forEach(annot => {
          // Only look for signatures
          if (annot instanceof Annotations.FreeHandAnnotation && annot.Subject === 'Signature') {
            // On XFDF Import
            if (info.imported) {
              // Read field ID from annotation
              const fieldName = annot.getCustomData('associatedField');
              const field = annotManager.getFieldManager().getField(fieldName);
              if (field) {
                // Set the annotation
                field.widgets[0].annot = annot;
                // Delay setting the style since the widget may not have mounted
                setTimeout(() => {
                  field.widgets[0].innerElement.style.display = 'none';
                }, 3000);
              }
            }
            // On sign widget
            else {
              // If the signature has the same position as the widget
              const associatedField = annotManager.getAnnotationsList().find(a => a instanceof Annotations.SignatureWidgetAnnotation && a.X === annot.X && a.Y === annot.Y);
              // Save field ID in annotation
              annot.setCustomData('associatedField', associatedField.fieldName);
            }
          }
        });
      }
    });

Andy Huang

Thank you Andy Huang for you quick reply.

I also want to know that, is there any way to lock the signature annotation, so it can’t be moved
My pdftron WebViewer version is:

UI version ‘7.0.0’
Core version ‘7.0.0’

Hello,

That is possible and there are two options. You can either use the NoMove property or the Locked property on the annotation.

https://www.pdftron.com/api/web/Core.Annotations.Annotation.html#Locked__anchor
https://www.pdftron.com/api/web/Core.Annotations.Annotation.html#NoMove__anchor

The difference is that the NoMove property only prevents it from being moved whereas Locked should lock everything. You may have to pair NoMove with NoResize and NoRotate.

Andy Huang