Distinguish between sign here and initials button


How to distinguish between the Sign Here and the Initials button in a locationSelected event ? I have base64 image data for both signature and initials. Now upon clicking the Sign Here and Initials button appropriate signature/initials will be added in the pdf doc. I have used the below code section. If there is any other way of achieving this, please suggest.

PS: I don’t want to select Signature/Initials from signature tool overlay.

signatureTool.addEventListener('locationSelected', (data) => {
     // if Sign here button clicked

    // if initials button clicked

Hi Lmran,

Thank you for contacting us regarding Webviewer.

I’ll inquire the information from the team and get back to you as soon as possible.

1 Like

Hi Lmran,

To identify between the “sign here” and “initials” button, you can use the SignatureWidgetAnnotation.requireInitials method. (Apryse WebViewer Class: SignatureWidgetAnnotation). This will return if the widget annotation is setup for initials or signatures.

You could also check our open-source UI project at webviewer-ui/onLocationSelected.js at 10.0 · PDFTron/webviewer-ui · GitHub to see how it is done.

Please let us know if this resolves your issue, thank you.


Hi Johnny_Kung,
Thanks for your reply. The following code resolves the issue.

signatureTool.addEventListener('locationSelected', async (_, widget) => {
      if (widget.requiresInitials()) {
           await signatureTool.setInitials(initialImageSource);
           await signatureTool.addInitials();

      } else {
           await signatureTool.setSignature(signatureImageSource);
           await signatureTool.addSignature();
1 Like