Requiring Signature Text to be changed

Which product are you using?
PDF.js Express Plus

PDF.js Express Version
image

Detailed description of issue
We are trying to add a way to avoid having the user be able to enter the word Guest in the typed signature.

Expected behaviour
To be able to attach to the signature-create button so we can return true or false if we approve of the signature, which will allow us to compare the text entered with what we allow.

Code snippet
Currently I have tried to attach it to the save event but this event is fired after the signature is created. We are looking for an even that fires before its created to approve or disapprove of the text entered.

 const sigTool = docViewer.getTool('AnnotationCreateSignature');
                    sigTool.addEventListener("signatureSaved", (annotation) => {
                        console.log(annotation);
                        console.log("Saved");
                    });

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:

Hey Eric,

Thanks for your question about Signature Widget.

The word “Guest” in the typed signature is related to the current user name. We can make this value empty and the Create button will be disabled. Also, we can check if the user types “Guest” again and the button will be disabled as well.

Let me know if this approach works for you and if so, here is a guide code

const { annotationManager } = instance.Core;

  annotationManager.setCurrentUser('');

  const iframeDoc = instance.UI.iframeWindow.document;
  const signatureInput = iframeDoc.querySelector('.text-signature-input');
  const signatureCreateButton = iframeDoc.querySelector('[data-element="textSignaturePanel"] .signature-create');

  signatureInput.addEventListener('input', (e) => {
    let inputValue = e.target.value.trim().toLowerCase();
    if (inputValue === 'guest') {
        signatureCreateButton.disabled = true;
    } else {
      signatureCreateButton.removeAttribute('disabled');
    }
  });

Hope this helps,

Thank you,
Dandara

1 Like