Adding Signature Fields
Digital signatures appear in signature fields, which are form fields that contain a graphic representation of the signature. Signature fields can be visible or invisible. Signers can use a pre-existing signature field, or a signature field can be programmatically added. In either case, the signature field must exist before a PDF document can be signed.
You can programmatically add a signature field by using the Signature service Java API or Signature web service API. You can add more than one signature field to a PDF document; however, each signature field name must be unique.
Summary of steps
To add a signature field to a PDF document, perform the following tasks:
- Include project files.
- Create a Signature client.
- Get a PDF document to which a signature field is added.
- Add a signature field.
- Save the PDF document as a PDF file.
Include project files
Include necessary files into your development project. If you are creating a client application using Java, include the necessary JAR files. If you are using web services, ensure that you include the proxy files.
The following JAR files must be added to your project’s classpath:
- adobe-livecycle-client.jar
- adobe-usermanager-client.jar
- adobe-signatures-client.jar
- adobe-utilities.jar (required if AEM Forms is deployed on JBoss)
- jbossall-client.jar (required if AEM Forms is deployed on JBoss)
Create a Signature client
Before you can programmatically perform a Signature service operation, you must create a Signature service client.
Get a PDF document to which a signature field is added
Obtain a PDF document to which a signature field is added.
Add a signature field
To successfully add a signature field to a PDF document, you specify coordinate values that identify the location of the signature field. (If you add an invisible signature field, these values are not required.) Also, you can specify which fields in the PDF document are locked after a signature is applied to the signature field.
Save the PDF document as a PDF file
After the Signature service adds a signature field to the PDF document, you can save the document as a PDF file so that users can open it in Acrobat or Adobe Reader.
See also
Add signature fields using the Java API
Add a signature field by using the Signature API (Java):
-
Include project files
Include client JAR files, such as adobe-signatures-client.jar, in your Java project’s classpath.
-
Create a Signature client
- Create a
ServiceClientFactory
object that contains connection properties. - Create a
SignatureServiceClient
object by using its constructor and passing theServiceClientFactory
object.
- Create a
-
Get a PDF document to which a signature field is added
- Create a
java.io.FileInputStream
object that represents the PDF document to which a signature field is added 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 thejava.io.FileInputStream
object.
- Create a
-
Add a signature field
-
Create a
PositionRectangle
object that specifies the signature field location by using its constructor. Within the constructor, specify coordinate values. -
If desired, create a
FieldMDPOptions
object that specifies the fields that are locked when a digital signature is applied to the signature field. -
Add a signature field to a PDF document by invoking the
SignatureServiceClient
object’saddSignatureField
method and passing the following values:- A
com.adobe.idp
.Document
object that represents the PDF document to which a signature field is added. - A string value that specifies the name of the signature field.
- A
java.lang.Integer
value that represents the page number to which a signature field is added. - A
PositionRectangle
object that specifies the location of the signature field. - A
FieldMDPOptions
object that specifies fields in the PDF document that are locked after a digital signature is applied to the signature field. This parameter value is optional, and you can passnull
.
- A
-
A
PDFSeedValueOptions
object that specifies various run-time values. This parameter value is optional, and you can passnull
.The
addSignatureField
method returns acom.adobe.idp
.Document
object that represents a PDF document that contains a signature field.
NOTE
You can invoke theSignatureServiceClient
object’saddInvisibleSignatureField
method to add an invisible signature field. -
-
Save the PDF document as a PDF file
- Create a
java.io.File
object and ensure that the file extension is .pdf. - Invoke the
com.adobe.idp
.Document
object’scopyToFile
method to copy the contents of theDocument
object to the file. Ensure that you use thecom.adobe.idp
.Document
object that was returned by theaddSignatureField
method.
- Create a
Add signature fields using the web service API
To add a signature field by using the Signature API (web service):
-
Include project files
Create a Microsoft .NET project that uses MTOM. Ensure that you use the following WSDL definition:
http://localhost:8080/soap/services/SignatureService?WSDL&lc_version=9.0.1
.NOTE
Replacelocalhost
with the IP address of the server hosting AEM Forms. -
Create a Signature client
-
Create a
SignatureServiceClient
object by using its default constructor. -
Create a
SignatureServiceClient.Endpoint.Address
object by using theSystem.ServiceModel.EndpointAddress
constructor. Pass a string value that specifies the WSDL to the AEM Forms service (for example,http://localhost:8080/soap/services/SignatureService?WSDL
). You do not need to use thelc_version
attribute. This attribute is used when you create a service reference.) -
Create a
System.ServiceModel.BasicHttpBinding
object by getting the value of theSignatureServiceClient.Endpoint.Binding
field. Cast the return value toBasicHttpBinding
. -
Set the
System.ServiceModel.BasicHttpBinding
object’sMessageEncoding
field toWSMessageEncoding.Mtom
. This value ensures that MTOM is used. -
Enable basic HTTP authentication by performing the following tasks:
- Assign the AEM forms user name to the field
SignatureServiceClient.ClientCredentials.UserName.UserName
. - Assign the corresponding password value to the field
SignatureServiceClient.ClientCredentials.UserName.Password
. - Assign the constant value
HttpClientCredentialType.Basic
to the fieldBasicHttpBindingSecurity.Transport.ClientCredentialType
. - Assign the constant value
BasicHttpSecurityMode.TransportCredentialOnly
to the fieldBasicHttpBindingSecurity.Security.Mode
.
- Assign the AEM forms user name to the field
-
-
Get a PDF document to which a signature field is added
- Create a
BLOB
object by using its constructor. TheBLOB
object is used to store the PDF document that will contain a signature field. - Create a
System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the PDF document and the mode in which to open the file. - Create a byte array that stores the content of the
System.IO.FileStream
object. You can determine the size of the byte array by getting theSystem.IO.FileStream
object’sLength
property. - Populate the byte array with stream data by invoking the
System.IO.FileStream
object’sRead
method and passing the byte array, the starting position, and the stream length to read. - Populate the
BLOB
object by assigning itsMTOM
property with the contents of the byte array.
- Create a
-
Add a signature field
Add a signature field to the PDF document by invoking the
SignatureServiceClient
object’saddSignatureField
method and passing the following values:- A
BLOB
object that represents the PDF document to which a signature field is added. - A string value that specifies the signature field name.
- An integer value that represents the page number to which a signature field is added.
- A
PositionRect
object that specifies the location of the signature field. - A
FieldMDPOptions
object that specifies fields in the PDF document that are locked after a digital signature is applied to the signature field. This parameter value is optional, and you can passnull
. - A
PDFSeedValueOptions
object that specifies various run-time values. This parameter value is optional, and you can passnull
.
The
addSignatureField
method returns aBLOB
object that represents a PDF document that contains a signature field. - A
-
Save the PDF document as a PDF file
- Create a
System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the PDF document that will contain the signature field and the mode in which to open the file. - Create a byte array that stores the content of the
BLOB
object that was returned by theaddSignatureField
method. Populate the byte array by getting the value of theBLOB
object’sbinaryData
data member. - Create a
System.IO.BinaryWriter
object by invoking its constructor and passing theSystem.IO.FileStream
object. - Write the contents of the byte array to a PDF file by invoking the
System.IO.BinaryWriter
object’sWrite
method and passing the byte array.
- Create a
Retrieving Signature Field Names
You can retrieve the names of all signature fields that are in a PDF document that you want to sign or certify. If you are unsure of the signature field names that are in a PDF document or you want to verify the names, you can programmatically retrieve them. The Signature service returns the fully qualified name of the signature field, such as form1[0].grantApplication[0].page1[0].SignatureField1[0]
.
Summary of steps
To retrieve signature field names, perform the following tasks:
- Include project files.
- Create a Signature client.
- Get the PDF document that contains signature fields.
- Retrieve the signature field names.
Include project files
Include necessary files into your development project. If you are creating a client application using Java, include the necessary JAR files. If you are using web services, ensure that you include the proxy files.
The following JAR files must be added to your project’s classpath:
- adobe-livecycle-client.jar
- adobe-usermanager-client.jar
- adobe-signatures-client.jar
- adobe-utilities.jar (required if AEM Forms is deployed on JBoss)
- jbossall-client.jar (required if AEM Forms is deployed on JBoss)
For information about the location of these JAR files, see Including AEM Forms Java library files.
Create a Signature client
Before you can programmatically perform a Signature service operation, you must create a Signature service client.
Get the PDF document that contains signature fields
Retrieve a PDF document that contains signature fields.
Retrieve the signature field names
You can retrieve signature field names after you retrieve a PDF document that contains one or more signature fields.
See also
Retrieve signature field names using the Java API
Retrieve signature field using the web service API
Retrieve signature field names using the Java API
Retrieve signature field names by using the Signature API (Java):
-
Include project files
Include client JAR files, such as the adobe-signatures-client.jar, in your Java project’s classpath.
-
Create a Signature client
- Create a
ServiceClientFactory
object that contains connection properties. - Create a
SignatureServiceClient
object by using its constructor and passing theServiceClientFactory
object.
- Create a
-
Get the PDF document that contains signature fields
- Create a
java.io.FileInputStream
object that represents the PDF document that contains signature fields 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 thejava.io.FileInputStream
object.
- Create a
-
Retrieve the signature field names
- Retrieve the signature field names by invoking the
SignatureServiceClient
object’sgetSignatureFieldList
method and passing thecom.adobe.idp.Document
object that contains the PDF document that contains signature fields. This method returns ajava.util.List
object, in which each element contains aPDFSignatureField
object. Using this object, you can obtain additional information about a signature field, such as whether it is visible. - Iterate through the
java.util.List
object to determine if there are signature field names. For each signature field in the PDF document, you can obtain a separatePDFSignatureField
object. To obtain the name of the signature field, invoke thePDFSignatureField
object’sgetName
method. This method returns a string value that specifies the signature field name.
- Retrieve the signature field names by invoking the
Retrieve signature field using the web service API
Retrieve signature field names using the Signature API (web service):
-
Include project files
Create a Microsoft .NET project that uses MTOM. Ensure that you use the following WSDL definition:
http://localhost:8080/soap/services/SignatureService?WSDL&lc_version=9.0.1
.NOTE
Replacelocalhost
with the IP address of the server hosting AEM Forms. -
Create a Signature client
-
Create a
SignatureServiceClient
object by using its default constructor. -
Create a
SignatureServiceClient.Endpoint.Address
object by using theSystem.ServiceModel.EndpointAddress
constructor. Pass a string value that specifies the WSDL to the AEM Forms service (for example,http://localhost:8080/soap/services/SignatureService?WSDL
). You do not need to use thelc_version
attribute. This attribute is used when you create a service reference.) -
Create a
System.ServiceModel.BasicHttpBinding
object by getting the value of theSignatureServiceClient.Endpoint.Binding
field. Cast the return value toBasicHttpBinding
. -
Set the
System.ServiceModel.BasicHttpBinding
object’sMessageEncoding
field toWSMessageEncoding.Mtom
. This value ensures that MTOM is used. -
Enable basic HTTP authentication by performing the following tasks:
- Assign the AEM forms user name to the field
SignatureServiceClient.ClientCredentials.UserName.UserName
. - Assign the corresponding password value to the field
SignatureServiceClient.ClientCredentials.UserName.Password
. - Assign the constant value
HttpClientCredentialType.Basic
to the fieldBasicHttpBindingSecurity.Transport.ClientCredentialType
. - Assign the constant value
BasicHttpSecurityMode.TransportCredentialOnly
to the fieldBasicHttpBindingSecurity.Security.Mode
.
- Assign the AEM forms user name to the field
-
-
Get the PDF document that contains signature fields
- Create a
BLOB
object by using its constructor. TheBLOB
object is used to store the PDF document that contains signature fields. - Create a
System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the PDF document and the mode in which to open the file. - Create a byte array that stores the content of the
System.IO.FileStream
object. You can determine the size of the byte array by getting theSystem.IO.FileStream
object’sLength
property. - Populate the byte array with stream data by invoking the
System.IO.FileStream
object’sRead
method and passing the byte array, the starting position, and the stream length to read. - Populate the
BLOB
object by assigning itsMTOM
field the byte array contents.
- Create a
-
Retrieve the signature field names
- Retrieve the signature field names by invoking
SignatureServiceClient
object’sgetSignatureFieldList
method and passing theBLOB
object that contains the PDF document that contains signature fields. This method returns aMyArrayOfPDFSignatureField
collection object where each element contains aPDFSignatureField
object. - Iterate through the
MyArrayOfPDFSignatureField
object to determine whether there are signature field names. For each signature field in the PDF document, you can obtain aPDFSignatureField
object. To obtain the name of the signature field, invoke thePDFSignatureField
object’sgetName
method. This method returns a string value that specifies the signature field name.
- Retrieve the signature field names by invoking
Modifying Signature Fields
You can modify signature fields that are in a PDF document by using the Java API and web service API. Modifying a signature field involves manipulating its signature field lock dictionary values or seed value dictionary values.
A field lock dictionary specifies a list of fields that are locked when the signature field is signed. A locked field prevents users from making changes to the field. A seed value dictionary contains constraining information that is used at the time the signature is applied. For example, you can change permissions that control the actions that can occur without invalidating a signature.
By modifying an existing signature field, you can change the PDF document to reflect changing business requirements. For example, a new business requirement may require locking all document fields after the document is signed.
This section explains how to modify a signature field by amending both field lock dictionary and seed value dictionary values. Changes made to the signature field lock dictionary result in all fields in the PDF document being locked when a signature field is signed. Changes made to the seed value dictionary prohibit specific types of changes to the document.
Summary of steps
To modify signature fields in a PDF document, perform the following tasks:
- Include project files.
- Create a Signature client.
- Get the PDF document that contains the signature field to modify.
- Set dictionary values.
- Modify the signature field.
- Save the PDF document as a PDF file.
Include project files
Include necessary files in your development project. If you are creating a client application by using Java, include the necessary JAR files. If you are using web services, ensure that you include the proxy files.
The following JAR files must be added to your project’s classpath:
- adobe-livecycle-client.jar
- adobe-usermanager-client.jar
- adobe-signatures-client.jar
- adobe-utilities.jar (required if AEM Forms is deployed on JBoss)
- jbossall-client.jar (required if AEM Forms is deployed on JBoss)
For information about the location of these JAR files, see Including LiveCycle Java library files.
Create a Signature client
Before you can programmatically perform a Signature service operation, you must create a Signature service client.
Get the PDF document that contains the signature field to modify
Retrieve a PDF document that contains the signature field to modify.
Set dictionary values
To modify a signature field, assign values to its field lock dictionary or seed value dictionary. Specifying signature field lock dictionary values involves specifying PDF document fields that are locked when the signature field is signed. (This section discusses how to lock all fields.)
The following seed value dictionary values can be set:
-
Revision checking: Specifies whether revocation checking is performed when a signature is applied to the signature field.
-
Certificate options: Assigns values to the certificate seed value dictionary. Before specifying certificate options, it is recommended that you become familiar with a certificate seed value dictionary. (See PDF Reference.)
-
Digest options: Assigns digest algorithms that are used for signing. Valid values are SHA1, SHA256, SHA384, SHA512, and RIPEMD160.
-
Filter: Specifies the filter that is used with the signature field. For example, you can use the Adobe.PPKLite filter. (See PDF Reference.)
-
Flag options: Specifies the flag values that are associated with this signature field. A value of 1 means that a signer must use only the specified values for the entry. A value of 0 means that other values are permitted. Here are the Bit positions:
- 1(Filter): The signature handler to be used to sign the signature field
- 2 (SubFilter): An array of names that indicate acceptable encodings to use when signing
- 3 (V): The minimum required version number of the signature handler to be used to sign the signature field
- 4 (Reasons): An array of strings that specify possible reasons for signing a document
- 5 (PDFLegalWarnings): An array of strings that specify possible legal attestations
-
Legal attestations: When a document is certified, it is automatically scanned for specific types of content that can make the visible contents of a document ambiguous or misleading. For example, an annotation can obscure text that is important for understanding what is being certified. The scanning process generates warnings that indicate the presence of this type of content. It also provides an additional explanation of the content that may have generated warnings.
-
Permissions: Specifies permissions that can be used on a PDF document without invalidating the signature.
-
Reasons: Specifies reasons why this document must be signed.
-
Time stamp: Specifies time-stamping options. You can, for example, set the URL of the time-stamping server that is used.
-
Version: Specifies the minimum version number of the signature handler to be used to sign the signature field.
Modify the signature field
After you create a Signature service client, retrieve the PDF document that contains the signature field to modify, and set dictionary values, you can instruct the Signature service to modify the signature field. The Signature service then returns a PDF document that contains the modified signature field. The original PDF document is not affected.
Save the PDF document as a PDF file
Save the PDF document that contains the modified signature field as a PDF file so that users can open it in Acrobat or Adobe Reader.
See also
Including AEM Forms Java library files
Modify signature fields using the Java API
Modify a signature field by using the Signature API (Java):
-
Include project files
Include client JAR files, such as the adobe-signatures-client.jar, in your Java project’s class path.
-
Create a Signature client
- Create a
ServiceClientFactory
object that contains connection properties. - Create a
SignatureServiceClient
object by using its constructor and passing theServiceClientFactory
object.
- Create a
-
Get the PDF document that contains the signature field to modify
- Create a
java.io.FileInputStream
object that represents the PDF document that contains the signature field to modify 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 thejava.io.FileInputStream
object.
- Create a
-
Set dictionary values
- Create a
PDFSignatureFieldProperties
object by using its constructor. APDFSignatureFieldProperties
object stores signature field lock dictionary and seed value dictionary information. - Create a
PDFSeedValueOptionSpec
object by using its constructor. This object lets you set seed value dictionary values. - Disallow changes to the PDF document by invoking the
PDFSeedValueOptionSpec
object’ssetMdpValue
method and passing theMDPPermissions.NoChanges
enumeration value. - Create a
FieldMDPOptionSpec
object by using its constructor. This object lets you set signature field lock dictionary values. - Lock all fields in the PDF document by invoking the
FieldMDPOptionSpec
object’ssetMdpValue
method and passing theFieldMDPAction.ALL
enumeration value. - Set seed value dictionary information by invoking the
PDFSignatureFieldProperties
object’ssetSeedValue
method and passing thePDFSeedValueOptionSpec
object. - Set signature field lock dictionary information by invoking the
PDFSignatureFieldProperties
object’ssetFieldMDP
method and passing theFieldMDPOptionSpec
object.
NOTE
To see all seed value dictionary values that you can set, see thePDFSeedValueOptionSpec
class reference. (See AEM Forms API Reference.) - Create a
-
Modify the signature field
Modify the signature field by invoking the
SignatureServiceClient
object’smodifySignatureField
method and passing the following values:- The
com.adobe.idp.Document
object that stores the PDF document that contains the signature field to modify - A string value that specifies the name of the signature field
- The
PDFSignatureFieldProperties
object that stores signature field lock dictionary and seed value dictionary information
The
modifySignatureField
method returns acom.adobe.idp.Document
object that stores a PDF document that contains the modified signature field. - The
-
Save the PDF document as a PDF file
- Create a
java.io.File
object and ensure that the file name extension is .pdf. - Invoke the
com.adobe.idp.Document
object’scopyToFile
method to copy the contents of thecom.adobe.idp.Document
object to the file. Ensure that you use thecom.adobe.idp.Document
object that themodifySignatureField
method returned.
- Create a
Modify signature fields using the web service API
Modify a signature field by using the Signature API (web service):
-
Include project files
Create a Microsoft .NET project that uses MTOM. Ensure that you use the following WSDL definition:
http://localhost:8080/soap/services/SignatureService?WSDL&lc_version=9.0.1
.NOTE
Replacelocalhost
with the IP address of the server hosting AEM Forms. -
Create a Signature client
-
Create a
SignatureServiceClient
object by using its default constructor. -
Create a
SignatureServiceClient.Endpoint.Address
object by using theSystem.ServiceModel.EndpointAddress
constructor. Pass a string value that specifies the WSDL to the AEM Forms service (for example,http://localhost:8080/soap/services/SignatureService?WSDL
). You do not need to use thelc_version
attribute. This attribute is used when you create a service reference.) -
Create a
System.ServiceModel.BasicHttpBinding
object by getting the value of theSignatureServiceClient.Endpoint.Binding
field. Cast the return value toBasicHttpBinding
. -
Set the
System.ServiceModel.BasicHttpBinding
object’sMessageEncoding
field toWSMessageEncoding.Mtom
. This value ensures that MTOM is used. -
Enable basic HTTP authentication by performing the following tasks:
- Assign the AEM forms user name to the field
SignatureServiceClient.ClientCredentials.UserName.UserName
. - Assign the corresponding password value to the field
SignatureServiceClient.ClientCredentials.UserName.Password
. - Assign the constant value
HttpClientCredentialType.Basic
to the fieldBasicHttpBindingSecurity.Transport.ClientCredentialType
. - Assign the constant value
BasicHttpSecurityMode.TransportCredentialOnly
to the fieldBasicHttpBindingSecurity.Security.Mode
.
- Assign the AEM forms user name to the field
-
-
Get the PDF document that contains the signature field to modify
- Create a
BLOB
object by using its constructor. TheBLOB
object is used to store the PDF document that contains the signature field to modify. - Create a
System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the PDF document and the mode in which to open the file. - Create a byte array that stores the content of the
System.IO.FileStream
object. You can determine the size of the byte array by getting theSystem.IO.FileStream
object’sLength
property. - Populate the byte array with stream data by invoking the
System.IO.FileStream
object’sRead
method and passing the byte array, the starting position, and the stream length to read. - Populate the
BLOB
object by assigning itsMTOM
property the contents of the byte array.
- Create a
-
Set dictionary values
- Create a
PDFSignatureFieldProperties
object by using its constructor. This object stores signature field lock dictionary and seed value dictionary information. - Create a
PDFSeedValueOptionSpec
object by using its constructor. This object lets you set seed value dictionary values. - Disallow changes to the PDF document by assigning the
MDPPermissions.NoChanges
enumeration value to thePDFSeedValueOptionSpec
object’smdpValue
data member. - Create a
FieldMDPOptionSpec
object by using its constructor. This object lets you set signature field lock dictionary values. - Lock all fields in the PDF document by assigning the
FieldMDPAction.ALL
enumeration value to theFieldMDPOptionSpec
object’smdpValue
data member. - Set seed value dictionary information by assigning the
PDFSeedValueOptionSpec
object to thePDFSignatureFieldProperties
object’sseedValue
data member. - Set signature field lock dictionary information by assigning the
FieldMDPOptionSpec
object to thePDFSignatureFieldProperties
object’sfieldMDP
data member.
NOTE
To see all seed value dictionary values that you can set, see thePDFSeedValueOptionSpec
class reference. (See AEM Forms API Reference). - Create a
-
Modify the signature field
Modify the signature field by invoking the
SignatureServiceClient
object’smodifySignatureField
method and passing the following values:- The
BLOB
object that stores the PDF document that contains the signature field to modify - A string value that specifies the name of the signature field
- The
PDFSignatureFieldProperties
object that stores signature field lock dictionary and seed value dictionary information
The
modifySignatureField
method returns aBLOB
object that stores a PDF document that contains the modified signature field. - The
-
Save the PDF document as a PDF file
- Create a
System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the PDF document that will contain the signature field, and the mode in which to open the file. - Create a byte array that stores the content of the
BLOB
object that theaddSignatureField
method returns. Populate the byte array by getting the value of theBLOB
object’sMTOM
data member. - Create a
System.IO.BinaryWriter
object by invoking its constructor and passing theSystem.IO.FileStream
object. - Write the contents of the byte array to a PDF file by invoking the
System.IO.BinaryWriter
object’sWrite
method and passing the byte array.
- Create a