Programming with LiveCycle ES2.5

Digitally sign PDF documents using the Java API

Digitally sign a PDF document by using the Signature API (Java):

  1. Include project files

        Include client JAR files, such as adobe-signatures-client.jar, in your Java project's classpath.

  2. Create a Signatures client
    • Create a ServiceClientFactory object that contains connection properties.
    • Create a SignatureServiceClient object by using its constructor and passing the ServiceClientFactory object.
  3. Get the PDF document to sign
    • Create a java.io.FileInputStream object that represents the PDF document to digitally sign by using its constructor and passing a string value that specifies the location of the PDF document.
    • Create a com.adobe.idp.Document object by using its constructor and passing the java.io.FileInputStream object.
  4. Sign the PDF document

        Sign the PDF document by invoking the SignatureServiceClient object's sign method and passing the following values:

      • A com.adobe.idp.Document object that represents the PDF document to sign.
      • A string value that represents the name of the signature field that will contain the digital signature.
      • A Credential object that represents the credential that is used to digitally sign the PDF document. Create a Credential object by invoking the Credential object's static getInstance method and passing a string value that specifies the alias value that corresponds to the security credential.
      • A HashAlgorithm object that specifies a static data member that represents the hash algorithm to use to digest the PDF document. For example, you can specify HashAlgorithm.SHA1 to use the SHA1 algorithm.
      • A string value that represents the reason why the PDF document was digitally signed.
      • A string value that represents the signer's contact information.
      • A PDFSignatureAppearanceOptions object that controls the appearance of the digital signature. For example, you can use this object to add a custom logo to a digital signature.
      • A java.lang.Boolean object that specifies whether to perform revocation checking on the signer's certificate.
      • An OCSPOptionSpec object that stores preferences for Online Certificate Status Protocol (OCSP) support. If revocation checking is not done, this parameter is not used and you can specify null.
      • A CRLPreferences object that stores certificate revocation list (CRL) preferences. If revocation checking is not done, this parameter is not used and you can specify null.
      • A TSPPreferences object that stores preferences for time stamp provider (TSP) support. This parameter is optional and can be null. For more information, see LiveCycle ES2.5 API References.

        The sign method returns a com.adobe.idp.Document object that represents the signed PDF document.

  5. Save the signed PDF document
    • Create a java.io.File object and ensure that the file extension is .pdf.
    • Invoke the com.adobe.idp.Document object's copyToFile method and pass java.io.File to copy the contents of the Document object to the file. Ensure that you use the com.adobe.idp.Document object that was returned by the sign method.

See also

Quick Start (EJB mode): Digitally signing a PDF document using the Java API

Quick Start (SOAP mode): Digitally signing a PDF document using the Java API

Including LiveCycle ES2.5 Java library files

Setting connection properties