Signature annotation not showing correctly after digitaly signed

Which product are you using?

PDF.js Express Version

(index) Value

UI version ‘8.1.0’
Core version ‘8.1.1’
Build ‘MTAvMjEvMjAyMXw2OGY2MTQ1NWU=’
WebViewer Server false
Full API false

Detailed description of issue

I have a digitally signed a pdf document with the library, however when I try
to add additional signer it shows the previous signature as “Sign Here”

Expected behaviour

The editor should show the signature image just as I open it as in Adobe Acrobat Reader
including a screenshot below:

Does your issue happen with every document, or just one?
{Answer here}

Link to document

Code snippet

loadViewer(file) {
    WebViewer({
      path: '../../../../assets/static/lib',
    }, this.viewer.nativeElement)
    .then(async instance => {
      const {  Annotations, annotationManager, documentViewer } = instance.Core;

      this.wvInstance = instance;

      instance.UI.loadDocument(file, { filename: file.name });


      documentViewer.addEventListener('annotationsLoaded', () => {
        const signatureWidgetAnnots = annotationManager.getAnnotationsList().filter(
          annot => annot instanceof Annotations.SignatureWidgetAnnotation
        );
  
      signatureWidgetAnnots.forEach((annot) => {
        annot.isSignedInitially().then((isSigned) => {
          if (isSigned) {
            console.log('is signed')
          } else {
            // if this signature field is not signed initially
          }
        });
       });
      })

      annotationManager.addEventListener('annotationChanged', (annots, action) => {
        const document = documentViewer.getDocument();

        if (action === 'add') {
          for (const annot of annots) {

            if (annot.Subject === 'Signature') {
              const { X, Y, Width, Height, PageNumber } = annot;

              const { width, height } = document.getPageInfo(PageNumber)
              this.signature = this.generateAnnotationImage(annot, 1)
              
              this.coordinates = { 
                x: X,
                y: height - Y
              };
            }
          }
        }
        if (action === 'modify') {
          for (const annot of annots) {
            if (annot.Subject === 'Signature') {
              const { X, Y, Width, Height, PageNumber } = annot;
              const { width, height } = document.getPageInfo(PageNumber);

              this.signature = this.generateAnnotationImage(annot, 1)
              this.coordinates = {
                x: X,
                y: height - Y
              };
            }
          }
        }
      });
    });
  }

The block quote is saying that annot.isSignedInitially() is undefined

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:

Hi There,

Thanks for your question. Part of the problem was resolved in the latest version, so I’d like to ask you to update your PDF.js Express version, please. Unfortunately, we found another issue that we need to investigate, but there is a workaround that you can use until we fix it.

The issue is, your signature will appear but the Sign Here widget will remain. Following is part of your code modified a bit to fix this problem.

loadViewer(file) {
    WebViewer({
      path: '../../../../assets/static/lib',
    }, this.viewer.nativeElement)
    .then(async instance => {
      const {  Annotations, annotationManager, documentViewer } = instance.Core;

      ...

   signatureWidgetAnnots.forEach((widget) => {
      const isSigned = !!widget.annot;
        if (isSigned) {
          console.log('is signed')
        } else {
        // if this signature field is not signed initially
          annotationManager.deleteAnnotations([widget]);
        }
      });
    })

     ...

    });
  }

Please let me know if this works for you.

Thank you,

Dandara

Thank you it works perfectly now !

1 Like

Please consider to ping me here when a new fix is available so i can update the version,

All the best,
Ezan

1 Like