Activate SignatureWidgetAnnotation programmatically

Hello, Tyler!

The code snippet helped me a lot. Thank you so much! I was also needing to resize the annotation and now I can.

But it still doesn’t work like the normal flow of clicking the widget. For that, I did two more things:

  1. I hid the widget after adding the annotation
signatureTool.addEventListener('signatureReady', async (annotation) => {
   ... // your code here
   signatureWidget.innerElement.style.display = 'none';
});
  1. Listen for the delete annotation event and shows the widget again
annotationManager.addEventListener(
   'annotationChanged',
   (annotations, action) => { 
      if (action === 'delete') {
         const signatureWidget = annotationManager
            .getAnnotationsList()
            .find( (annot) =>
               annot instanceof Annotations.SignatureWidgetAnnotation &&
               annot.getAssociatedSignatureAnnotation()?.Id === annotations[0].Id);

         signatureWidget.innerElement.style.display = 'block';
      }
   },
);

I believe the problem is now resolved.
Thanks a lot again, it helped me a lot to get to know PDF.js Express better.

Best regards,
Vicente!