How to associate custom data with a signature?

Product: Webviewer

Product Version: 8.0.1

Please give a brief summary of your issue:

Currently, when a signature is added to the page I have no custom data attached to it, which makes it difficult for me to implement business logic around users adding their signatures to documents.

Is there some way to get the custom data on a SignatureAnnotationWidget to transfer to the signature annotation that’s created by the user? Or is there an alternative way to add custom data to a signature before it’s created?

Hi @martin.jones,

I think what you could do here is add an event listener on the SignatureTool to determine when a signature is added. When it is added, you can then add your desired custom data to this annotation.

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

  const signatureTool = documentViewer.getTool(Tools.ToolNames.SIGNATURE);
  signatureTool.addEventListener('annotationAdded', (annotation) => {
    console.log({ annotation})
  });

https://www.pdftron.com/api/web/Core.Tools.SignatureCreateTool.html#event:annotationAdded__anchor

Also, the SignatureWidget itself has a reference to the annotation that is created by the user to sign it, so you could also leverage that:
https://www.pdftron.com/api/web/Core.Annotations.SignatureWidgetAnnotation.html#toc1__anchor

Best Regards,
Armando Bollain
Software Developer
PDFTron Systems, Inc.