Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getAnnotations() promise not being resolved when page contains signature #10347

Closed
luk-lo opened this issue Dec 11, 2018 · 0 comments · May be fixed by brokermint/pdf.js#1
Closed

getAnnotations() promise not being resolved when page contains signature #10347

luk-lo opened this issue Dec 11, 2018 · 0 comments · May be fixed by brokermint/pdf.js#1

Comments

@luk-lo
Copy link

luk-lo commented Dec 11, 2018

When a pdf page contains 'Sig' type widget annotations and those annotations have a signature as their fieldValue, the promise returned by page.getAnnotations() does not resolve.

Attach (recommended) or Link to PDF file here:
PDF with 'normal' annotations: http://www.pdfill.com/example/pdf_commenting_new.pdf
PDF with signature annotation: https://blogs.adobe.com/security/SampleSignedPDFDocument.pdf

Steps to reproduce:

// PDF without signature annotations works properly, use {data: pdfData} for a demonstration
var loadingTask = pdfjsLib.getDocument({data: pdfDataSigned});
loadingTask.promise.then(function(pdf) {
  console.log('PDF loaded');
  
  // Fetch the first page
  var pageNumber = 1;
  pdf.getPage(pageNumber).then(function(page) {
    console.log('Page loaded');
    page.getAnnotations().then(function(annotations) {
        // this is never executed if the page has signatures
        console.log('annotations loaded');
        for (let i = 0; i < annotations.length; i++) {
          console.log(annotations[i].subtype);
        }
      }, function (reason) {
      // this also does not happen if the page has signatures
      // Annotations loading error
      console.log(reason);
      });    
  });
}, function (reason) {
  // PDF loading error
  console.error(reason);
});

pdfDataSigned and pdfData are included in the fiddle as base64, which is too long to include here.
Fiddle demo (I recommend scrolling to the end of the javascript panel):
https://jsfiddle.net/luk_lo/mq9nyadh/1/

This may be related to #8429 but the provided fix is not helpful as it will prevent signature annotations from being returned by getAnnotations.
This bug is probably caused by the large fieldValue of the AnnotationsWidget as setting this.fieldValue = true; after the line

this.setFlags(AnnotationFlag.HIDDEN);
fixes the issue (of course the signature annotations returned by getAnnotations then do not have their proper fieldValue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants