Free Support Forum - aspose.com

Get signature info from signed pdf (Java)

Hi,

I have signed a PDF document via ASPOSE. And then I want to get information about the person or authority signing the document. And I get null results.

code.zip (5.5 KB)
If you need, In attached you can find code for signing-pdf, code for getting signature-information, and used .pfx file.

In aspose.word I could fetch the needed information

for (DigitalSignature digitalSignature : document.getDigitalSignatures()) {
subjects.add(digitalSignature.getSubjectName());
}

@razmik.mkrtchyan

You may please try using following code snippet in order to get Signer Name. However, if you face any issue, please share the PDF document from which you are trying to extract it. We will test the scenario in our environment and address it accordingly.

com.aspose.pdf.facades.PdfFileSignature pdfSign = new com.aspose.pdf.facades.PdfFileSignature();
pdfSign.bindPdf(dataDir + "input.pdf");
if (pdfSign.containsSignature()) {
 java.util.List<String> sigNames = pdfSign.getSignNames();
  if (sigNames.size() > 0) {
     for(String s:sigNames)
          System.out.println(pdfSign.getSignerName(s));
   }
 }
 pdfSign.close();

@asad.ali

Thank you for your response!

It didn’t work, returns null.

pdfSign.containsSignature() is true
pdfSign.getSignNames() Restruns “Singature1” - which I don’t know from where is it.
And pdfSign.getSignerName(s) returns null

**response.pdf (307.7 KB)
**

In attached you can find signed document. (signature is on the first page)

@razmik.mkrtchyan

We further tried following code snippet with Aspose.PDF for Java 20.6 to extract signature information but, we did not get much success:

Document pdfDocument = new Document(dataDir + "response.pdf");
        for(com.aspose.pdf.Field field:pdfDocument.getForm().getFields()){
            if(field instanceof SignatureField){
                SignatureField s = (SignatureField)field;
                System.out.println(s.getSignature().getAuthority());
                System.out.println(s.getSignature().getContactInfo());
                System.out.println(s.getSignature().getReason());
            }
        }

Therefore, we have logged an issue as PDFJAVA-39571 in our issue tracking system for the sake of further investigation. We will look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.

We are sorry for the inconvenience.

1 Like

@asad.ali
Thanks,I will wait!