|
The aim of this example is to use the TrustedX signing service to sign a PDF document. To understand this example, we recommend that you first understand the CMS/PKCS#7 Signature Generation example.
To try this example, you must download the file, sampleSW12.zip, and follow the instructions in Configuration of the Environment.
As in the case of the CMS/PKCS#7 Signature Generation example, you must use a SmartSignRequest object to make a signing request; in this case the signature profile will be PDF.
SmartSignRequest ssr = new SmartSignRequest(host); ssr.setProfile(Constants.Profile.PDF);
We enter the data to be signed using the setInputPdfBase64Data() function and, as indicated in the method, we enter the data encoded in Base64
ssr.setInputPdfBase64Data(Util.readBinaryFileB64(path_in + filename));
In the case of PDF signatures, we can indicate a number of attributes that the signature must have. This example defines the following attributes: the signature validation method used by AdobeReader (validationMethod), the signature position (signaturePosition) and the type of signature used (signatureAlg). We include these properties using the setPdfSignatureInfo() method which receives a string containing the XML with the defined properties.
ssr.setPdfSignatureInfo(pdfSignatureInfo);
Once all the data has been entered in the request, we invoke the send() operation to send the request to the host and collect the response in a SmartSignResponse object.
SmartSignResponse ssrs = ssr.send();
After executing the example, we obtain a response (see below) and a document with the signature.
File saved successfully on: data/output/demo-file-signed.pdf
|