Skip to content
Guides

Read Digital Signature Information

You can read various pieces of information from a document's digital signature, including the signature itself, the signer of the signature, and certain details of the signer's digital certificate.

For a comprehensive list of retrievable information, please refer to the API Reference.

This example shows how to read digital signature information:

java
CPDFDocument document = new CPDFDocument(context);
document.open(FileUtils.getAssetsTempFile(context, "Signed.pdf"));
for (int i = 0; i < document.getSignatureCount(); i++) {
    CPDFSignature signature = document.getPdfSignature(i);
    // Check if the signer array exists and is not empty
    if (signature.getSignerArr() != null && signature.getSignerArr().length > 0) {
        CPDFSigner signer = signature.getSignerArr()[0];
        CPDFOwnerInfo subject = signer.getCert().getCertInfo().getSubject();
        System.out.println("Name: " + signature.getName());
        System.out.println("Location: " + signature.getLocation());
        System.out.println("Reason: " + signature.getReason());
        System.out.println("Date: " + DateUtil.transformPDFDate(signature.getDate()));
        System.out.println("Subject: " + subject.toString());
    }
}
kotlin
val document = CPDFDocument(context)
document.open(getAssetsTempFile(context, "Signed.pdf"))
for (i in 0 until document.signatureCount) {
  val signature = document.getPdfSignature(i)
  // Check if the signer array exists and is not empty
  if (signature.signerArr != null && signature.signerArr.isNotEmpty()) {
    val signer = signature.signerArr[0]
    val subject = signer.cert.certInfo.subject
    println("Name: ${signature.name}")
    println("Location: ${signature.location}")
    println("Reason: ${signature.reason}")
    println("Date: ${transformPDFDate(signature.date)}")
    println("Subject: $subject")
  }
}

The Connection Between Digital Signatures, Signers, and Digital Certificates

A digital signature is generated by encrypting a document using the private key of the signer and then verifying the validity of the signature using the public key from the signer's certificate. The signature, signer, and digital certificate constitute a crucial part of digital signatures in a PDF document.

In most cases, one signature corresponds to one signer. However, in some situations, a digital signature can include multiple signers, each with their own certificate chain. This multi-signer mechanism can be very useful in certain application scenarios because it allows multiple entities to digitally sign the same document, each using their certificate and private key.