Edit in GitHubLog an issue

PDF Electronic Seal API

API Parameters

Signature Format (signatureFormat)

Specifies a supported digital signature format:

  • PADES : This is the latest and improved signature format which is more strict, concrete, and secure. For details, see ISO 32000-2 and ETSI EN 319 142-1.
  • PKCS7 : This signature format is less stringent than PADES since it permits more PDF changes without invalidating the digital signature. This is the default signature format. For details, see ISO 32000-1.

TSP Credential Information (cscCredentialOptions) : Required

TSP parameters encapsulate the sealer's certificate credential as well as the associated authentication and authorization data.

  • TSP Name (providerName) : Required : Specifies the name of the Trust Service Provider used to generate the certificate. Presently, only TSPs supporting the OAuth 2.0 client credential authorization flow are supported. The table below provides the provider name mapping for each supported Trust Service Provider. TSP Name Mapping

  • TSP Credential Id (credentialId) : Required : Specifies the Digital ID stored with the TSP that should be used for sealing.

  • TSP Authorization Context (authorizationContext) : Required : Encapsulates the authorization data required to communicate with the TSPs.

    • Access Token (accessToken) : Required : Specifies the access token used to authorize access to the CSC provider hosted APIs.
    • Token Type (tokenType): Specifies the type of access token. Default value is "Bearer".
  • TSP Credential Authorization Parameter (credentialAuthParameters) : Required : Encapsulates the credential authorization information required to authorize access to their digital certificate.

    • PIN (pin) : Required : Specifies the PIN associated with TSP provided credential ID.

Seal Field Parameters (sealFieldOptions) : Required

The seal field parameters are required to create a new signature field or use an existing signature field.

  • Field Name (fieldName) : Required : Specifies the signature field's name. This must be a non-empty string. If signature field with this field name already exists, that field is used. else a signature field with this name will be created.

  • Visible (visible): Specifies whether the signature field should be visible or hidden. The default value of true creates a visible seal.

  • Page Number (pageNumber) : Required : Specifies the page number to which the signature field should be attached. Page numbers are 1-based. It is only required if the signature field does not exist in the pdf document. If this is provided along with the signature field then the page number should be same on which signature field is present in the document, else an error is thrown.

  • Location (location) : Required : Specifies the coordinates of the seal appearance's bounding box in default PDF user space units. The location is only required if the signature field does not exist in the pdf document. If this is provided along with the existing signature field, then it is ignored.

    • Left (left) : Required : The left x-coordinate
    • Bottom (bottom) : Required : The bottom y-coordinate
    • Right (right) : Required : The right x-coordinate
    • Top (top) : Required : The top y-coordinate

To add the signature field explicitly, see how to place a signature field in a PDF.

Seal Appearance Parameters (sealAppearanceOptions)

Specifies seal field appearance parameters. These are an enumerated set of display items: NAME, DATE, DISTINGUISHED_NAME, LABELS and SEAL_IMAGE.

  • Display Options (displayOptions): Specifies the information to display in the seal. NAME and LABELS are the default values.

    • NAME: Specifies that the certificate owner's name should be displayed. Display Options
    • DATE: Specifies that the sealing date/time should be displayed. This value should not be mistaken for a signed timestamp from a timestamp authority. Display Options
    • DISTINGUISHED_NAME: Specifies that the distinguished name information from the digital certificate should be displayed. Display Options
    • LABELS: Specifies that text labels should be displayed. Display Options
    • SEAL_IMAGE: Specifies the seal image should be displayed. Display Options If SEAL_IMAGE is given in appearance parameters and seal image is not passed in the request, the default Acrobat trefoil image is used. Display Options

Example JSON

Copied to your clipboard
1{
2 "signatureFormat": "PADES",
3 "cscCredentialOptions": {
4 "authorizationContext": {
5 "accessToken": "<ACCESS_TOKEN>",
6 "tokenType": "Bearer"
7 },
8 "credentialAuthParameters": {
9 "pin": "<PIN>"
10 },
11 "providerName": "<PROVIDER_NAME>",
12 "credentialId": "<CREDENTIAL_ID>"
13 },
14 "sealFieldOptions": {
15 "pageNumber": 1,
16 "fieldName": "Signature1",
17 "visible": true,
18 "location": {
19 "top": 300,
20 "bottom": 250,
21 "left": 300,
22 "right": 500
23 }
24 },
25 "sealAppearanceOptions": {
26 "displayOptions": [
27 "NAME",
28 "DATE",
29 "LABELS",
30 "DISTINGUISHED_NAME",
31 "SEAL_IMAGE"
32 ]
33 }
34}

API limitations


  • Input PDF size: Input PDF files up to a maximum of 100 MB are supported.
  • Seal Image size: Seal Image files up to a maximum of 5 MB are supported.
  • Seal Image formats: Supported Seal Image formats are JPEG(image/jpeg), PNG(image/png) and PDF(application/pdf).
  • Password-protected Files: Encrypted or Password-protected PDFs are not supported for applying electronic seal.
  • Signed/Sealed Files: Any PDF which is already signed, certified or sealed cannot be used for applying electronic seal.
  • Input PDF version: Input PDF with version less than 1.3 are not supported.
  • Usage Rights File: Input PDF having usage rights are not supported.

REST API

See our public API Reference for PDF Electronic Seal API.

Apply Electronic Seal with default appearance on PDF

The sample below performs electronic seal operation with default appearance on a given PDF.

Please refer to the API usage guide to understand how to use our APIs.

Copied to your clipboard
1// Get the samples from https://www.adobe.com/go/pdftoolsapi_java_samples
2// Run the sample:
3// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.electronicseal.ElectronicSeal
4
5package com.adobe.pdfservices.operation.samples.electronicseal;
6
7public class ElectronicSeal {
8
9 // Initialize the logger.
10 private static final Logger LOGGER = LoggerFactory.getLogger(ElectronicSeal.class);
11
12 public static void main(String[] args) {
13 try {
14
15 // Initial setup, create credentials instance.
16 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()
17 .withClientId("PDF_SERVICES_CLIENT_ID")
18 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")
19 .build();
20
21 // Create an ExecutionContext using credentials.
22 ExecutionContext executionContext = ExecutionContext.create(credentials);
23
24 //Get the input document to perform the sealing operation
25 FileRef sourceFile = FileRef.createFromLocalFile("src/main/resources/sampleInvoice.pdf");
26
27 //Get the background seal image for signature , if required.
28 FileRef sealImageFile = FileRef.createFromLocalFile("src/main/resources/sampleSealImage.png");
29
30 //Set the Seal Field Name to be created in input PDF document.
31 String sealFieldName = "Signature1";
32
33 //Set the page number in input document for applying seal.
34 Integer sealPageNumber = 1;
35
36 //Set if seal should be visible or invisible.
37 Boolean sealVisible = true;
38
39 //Create FieldLocation instance and set the coordinates for applying signature
40 FieldLocation fieldLocation = new FieldLocation(150, 250, 350, 200);
41
42 //Create FieldOptions instance with required details.
43 FieldOptions fieldOptions = new FieldOptions.Builder(sealFieldName)
44 .setFieldLocation(fieldLocation)
45 .setPageNumber(sealPageNumber)
46 .setVisible(sealVisible)
47 .build();
48
49 //Set the name of TSP Provider being used.
50 String providerName = "<PROVIDER_NAME>";
51
52 //Set the access token to be used to access TSP provider hosted APIs.
53 String accessToken = "<ACCESS_TOKEN>";
54
55 //Set the credential ID.
56 String credentialID = "<CREDENTIAL_ID>";
57
58 //Set the PIN generated while creating credentials.
59 String pin = "<PIN>";
60
61 //Create CSCAuthContext instance using access token and token type.
62 CSCAuthContext cscAuthContext = new CSCAuthContext(accessToken, "Bearer");
63
64 //Create CertificateCredentials instance with required certificate details.
65 CertificateCredentials certificateCredentials = CertificateCredentials.cscCredentialBuilder()
66 .withProviderName(providerName)
67 .withCredentialID(credentialID)
68 .withPin(pin)
69 .withCSCAuthContext(cscAuthContext)
70 .build();
71
72 //Create SealOptions instance with sealing parameters.
73 SealOptions sealOptions = new SealOptions.Builder(certificateCredentials, fieldOptions).build();
74
75 //Create the PDFElectronicSealOperation instance using the SealOptions instance
76 PDFElectronicSealOperation pdfElectronicSealOperation = PDFElectronicSealOperation.createNew(sealOptions);
77
78 //Set the input source file for PDFElectronicSealOperation instance
79 pdfElectronicSealOperation.setInput(sourceFile);
80
81 //Set the optional input seal image for PDFElectronicSealOperation instance
82 pdfElectronicSealOperation.setSealImage(sealImageFile);
83
84 //Execute the operation
85 FileRef result = pdfElectronicSealOperation.execute(executionContext);
86
87 //Save the output at specified location
88 result.saveAs("output/sealedOutput.pdf");
89
90
91 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {
92 LOGGER.error("Exception encountered while executing operation", ex);
93 }
94 }
95}
96

Apply Electronic Seal with customized appearance on PDF

The sample below performs electronic seal operation with customized appearance on a given PDF.

Please refer to the API usage guide to understand how to use our APIs.

Copied to your clipboard
1// Get the samples from https://github.com/adobe/pdfservices-java-sdk-samples/tree/beta
2// Run the sample:
3// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.electronicseal.ElectronicSealWithAppearanceOptions
4
5package com.adobe.pdfservices.operation.samples.electronicseal;
6
7public class ElectronicSealWithAppearanceOptions {
8
9 // Initialize the logger.
10 private static final Logger LOGGER = LoggerFactory.getLogger(ElectronicSeal.class);
11
12 public static void main(String[] args) {
13 try {
14
15 // Initial setup, create credentials instance.
16 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()
17 .withClientId("PDF_SERVICES_CLIENT_ID")
18 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")
19 .build();
20
21 // Create an ExecutionContext using credentials.
22 ExecutionContext executionContext = ExecutionContext.create(credentials);
23
24 //Get the input document to perform the sealing operation
25 FileRef sourceFile = FileRef.createFromLocalFile("src/main/resources/sampleInvoice.pdf");
26
27 //Get the background seal image for signature , if required.
28 FileRef sealImageFile = FileRef.createFromLocalFile("src/main/resources/sampleSealImage.png");
29
30 //Create AppearanceOptions and add the required signature display items to it
31 AppearanceOptions appearanceOptions = new AppearanceOptions();
32 appearanceOptions.addItem(AppearanceItem.NAME);
33 appearanceOptions.addItem(AppearanceItem.LABELS);
34 appearanceOptions.addItem(AppearanceItem.DATE);
35 appearanceOptions.addItem(AppearanceItem.SEAL_IMAGE);
36 appearanceOptions.addItem(AppearanceItem.DISTINGUISHED_NAME);
37
38 //Set the Seal Field Name to be created in input PDF document.
39 String sealFieldName = "Signature1";
40
41 //Set the page number in input document for applying seal.
42 Integer sealPageNumber = 1;
43
44 //Set if seal should be visible or invisible.
45 Boolean sealVisible = true;
46
47 //Create FieldLocation instance and set the coordinates for applying signature
48 FieldLocation fieldLocation = new FieldLocation(150, 250, 350, 200);
49
50 //Create FieldOptions instance with required details.
51 FieldOptions fieldOptions = new FieldOptions.Builder(sealFieldName)
52 .setFieldLocation(fieldLocation)
53 .setPageNumber(sealPageNumber)
54 .setVisible(sealVisible)
55 .build();
56
57 //Set the name of TSP Provider being used.
58 String providerName = "<PROVIDER_NAME>";
59
60 //Set the access token to be used to access TSP provider hosted APIs.
61 String accessToken = "<ACCESS_TOKEN>";
62
63 //Set the credential ID.
64 String credentialID = "<CREDENTIAL_ID>";
65
66 //Set the PIN generated while creating credentials.
67 String pin = "<PIN>";
68
69 //Create CSCAuthContext instance using access token and token type.
70 CSCAuthContext cscAuthContext = new CSCAuthContext(accessToken, "Bearer");
71
72 //Create CertificateCredentials instance with required certificate details.
73 CertificateCredentials certificateCredentials = CertificateCredentials.cscCredentialBuilder()
74 .withProviderName(providerName)
75 .withCredentialID(credentialID)
76 .withPin(pin)
77 .withCSCAuthContext(cscAuthContext)
78 .build();
79
80 //Create SealOptions instance with all the sealing parameters.
81 SealOptions sealOptions = new SealOptions.Builder(certificateCredentials, fieldOptions)
82 .withAppearanceOptions(appearanceOptions).build();
83
84 //Create the PDFElectronicSealOperation instance using the SealOptions instance
85 PDFElectronicSealOperation pdfElectronicSealOperation = PDFElectronicSealOperation.createNew(sealOptions);
86
87 //Set the input source file for PDFElectronicSealOperation instance
88 pdfElectronicSealOperation.setInput(sourceFile);
89
90 //Set the optional input seal image for PDFElectronicSealOperation instance
91 pdfElectronicSealOperation.setSealImage(sealImageFile);
92
93 //Execute the operation
94 FileRef result = pdfElectronicSealOperation.execute(executionContext);
95
96 //Save the output at specified location
97 result.saveAs("output/sealedOutput.pdf");
98
99
100 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {
101 LOGGER.error("Exception encountered while executing operation", ex);
102 }
103 }
104}
105
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2023 Adobe. All rights reserved.