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.

Document Level Permission (documentLevelPermission)

Specifies the DocMDP (i.e. Document Modification Detection and Prevention) permissions. These permissions are applied to the output electronically sealed document.

  • NO_CHANGES_ALLOWED : No changes to the document are permitted. Any change to the document will invalidate the signature.
  • FORM_FILLING : Allowed changes are filling in forms, instantiating page templates, and performing approval signatures. This is also the default document level permission, if not specified by the user.
  • FORM_FILLING_AND_ANNOTATIONS : In addition to above, annotation creation, deletion, and modification are also allowed.

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.

TSA Information (tsaOptions) :

TSA parameters encapsulate the timestamping URL and credentials.

  • TSA URL (url) : Required : Specifies the TSA URL to be used for getting timestamp token.

  • TSA Credential Authorization Parameter (credentialAuthParameters) : Encapsulates the credential information required to authenticate the TSA URL.

    • TSA Username (username) : Specify the username for authenticating TSA URL.
    • TSA Password (password) : Specify the password for authenticating TSA URL.

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 needs to be visible and, it 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. This parameter will be ignored in case of invisible signature field.

  • 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. This parameter will also be ignored for invisible signature field.

    • 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 "documentLevelPermission": "FORM_FILLING",
4 "cscCredentialOptions": {
5 "authorizationContext": {
6 "accessToken": "<ACCESS_TOKEN>",
7 "tokenType": "Bearer"
8 },
9 "credentialAuthParameters": {
10 "pin": "<PIN>"
11 },
12 "providerName": "<PROVIDER_NAME>",
13 "credentialId": "<CREDENTIAL_ID>"
14 },
15 "tsaOptions": {
16 "url": "<TIMESTAMP_URL>",
17 "credentialAuthParameters": {
18 "username": "<USERNAME>",
19 "password": "<PASSWORD>"
20 }
21 },
22 "sealFieldOptions": {
23 "pageNumber": 1,
24 "fieldName": "Signature1",
25 "visible": true,
26 "location": {
27 "left" : 150,
28 "top": 250,
29 "bottom": 350,
30 "right": 200
31 }
32 },
33 "sealAppearanceOptions": {
34 "displayOptions": [
35 "NAME",
36 "DATE",
37 "LABELS",
38 "DISTINGUISHED_NAME",
39 "SEAL_IMAGE"
40 ]
41 }
42}

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 (InputStream inputStream = Files.newInputStream(new File("src/main/resources/sampleInvoice.pdf").toPath());
14 InputStream inputStreamSealImage = Files.newInputStream(new File("src/main/resources/sampleSealImage.png").toPath())) {
15 // Initial setup, create credentials instance
16 Credentials credentials = new ServicePrincipalCredentials(
17 System.getenv("PDF_SERVICES_CLIENT_ID"),
18 System.getenv("PDF_SERVICES_CLIENT_SECRET"));
19
20 // Creates a PDF Services instance
21 PDFServices pdfServices = new PDFServices(credentials);
22
23 // Creates an asset(s) from source file(s) and upload
24 Asset asset = pdfServices.upload(inputStream, PDFServicesMediaType.PDF.getMediaType());
25 Asset sealImageAsset = pdfServices.upload(inputStreamSealImage, PDFServicesMediaType.PNG.getMediaType());
26
27 // Set the document level permission to be applied for output document
28 DocumentLevelPermission documentLevelPermission = DocumentLevelPermission.FORM_FILLING;
29
30 // Sets the Seal Field Name to be created in input PDF document.
31 String sealFieldName = "Signature1";
32
33 // Sets the page number in input document for applying seal.
34 Integer sealPageNumber = 1;
35
36 // Sets if seal should be visible or invisible.
37 Boolean sealVisible = true;
38
39 // Creates 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 // Sets the name of TSP Provider being used.
50 String providerName = "<PROVIDER_NAME>";
51
52 // Sets the access token to be used to access TSP provider hosted APIs.
53 String accessToken = "<ACCESS_TOKEN>";
54
55 // Sets the credential ID.
56 String credentialID = "<CREDENTIAL_ID>";
57
58 // Sets the PIN generated while creating credentials.
59 String pin = "<PIN>";
60
61 // Creates 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 parameters for the job
73 PDFElectronicSealParams pdfElectronicSealParams = PDFElectronicSealParams
74 .pdfElectronicSealParamsBuilder(certificateCredentials, fieldOptions)
75 .withDocumentLevelPermission(documentLevelPermission)
76 .build();
77
78 // Creates a new job instance
79 PDFElectronicSealJob pdfElectronicSealJob = new PDFElectronicSealJob(asset, pdfElectronicSealParams);
80
81 // Sets the optional input seal image for PDFElectronicSealOperation instance
82 pdfElectronicSealJob.setSealImageAsset(sealImageAsset);
83
84 // Submit the job and gets the job result
85 String location = pdfServices.submit(pdfElectronicSealJob);
86 PDFServicesResponse<PDFElectronicSealResult> pdfServicesResponse = pdfServices.getJobResult(location, PDFElectronicSealResult.class);
87
88 // Get content from the resulting asset(s)
89 Asset resultAsset = pdfServicesResponse.getResult().getAsset();
90 StreamAsset streamAsset = pdfServices.getContent(resultAsset);
91
92 // Creates an output stream and copy stream asset's content to it
93 Files.createDirectories(Paths.get("output/"));
94 OutputStream outputStream = Files.newOutputStream(new File("output/sealedOutput.pdf").toPath());
95 LOGGER.info("Saving asset at output/sealedOutput.pdf");
96 IOUtils.copy(streamAsset.getInputStream(), outputStream);
97 outputStream.close();
98 } catch (ServiceApiException | IOException | SDKException | ServiceUsageException ex) {
99 LOGGER.error("Exception encountered while executing operation", ex);
100 }
101 }
102}
103

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(ElectronicSealWithAppearanceOptions.class);
11
12 public static void main(String[] args) {
13 try (InputStream inputStream = Files.newInputStream(new File("src/main/resources/sampleInvoice.pdf").toPath());
14 InputStream inputStreamSealImage = Files.newInputStream(new File("src/main/resources/sampleSealImage.png").toPath())) {
15 // Initial setup, create credentials instance
16 Credentials credentials = new ServicePrincipalCredentials(
17 System.getenv("PDF_SERVICES_CLIENT_ID"),
18 System.getenv("PDF_SERVICES_CLIENT_SECRET"));
19
20 // Creates a PDF Services instance
21 PDFServices pdfServices = new PDFServices(credentials);
22
23 // Creates an asset(s) from source file(s) and upload
24 Asset asset = pdfServices.upload(inputStream, PDFServicesMediaType.PDF.getMediaType());
25 Asset sealImageAsset = pdfServices.upload(inputStreamSealImage, PDFServicesMediaType.PNG.getMediaType());
26
27 // Set the document level permission to be applied for output document
28 DocumentLevelPermission documentLevelPermission = DocumentLevelPermission.FORM_FILLING;
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
39 // Sets the Seal Field Name to be created in input PDF document.
40 String sealFieldName = "Signature1";
41
42 // Sets the page number in input document for applying seal.
43 Integer sealPageNumber = 1;
44
45 // Sets if seal should be visible or invisible.
46 Boolean sealVisible = true;
47
48 // CreatesFieldLocation instance and set the coordinates for applying signature
49 FieldLocation fieldLocation = new FieldLocation(150, 250, 350, 200);
50
51 // Create FieldOptions instance with required details.
52 FieldOptions fieldOptions = new FieldOptions.Builder(sealFieldName)
53 .setFieldLocation(fieldLocation)
54 .setPageNumber(sealPageNumber)
55 .setVisible(sealVisible)
56 .build();
57
58 // Sets the name of TSP Provider being used.
59 String providerName = "<PROVIDER_NAME>";
60
61 // Sets the access token to be used to access TSP provider hosted APIs.
62 String accessToken = "<ACCESS_TOKEN>";
63
64 // Sets the credential ID.
65 String credentialID = "<CREDENTIAL_ID>";
66
67 // Sets the PIN generated while creating credentials.
68 String pin = "<PIN>";
69
70 // Creates CSCAuthContext instance using access token and token type.
71 CSCAuthContext cscAuthContext = new CSCAuthContext(accessToken, "Bearer");
72
73 // Create CertificateCredentials instance with required certificate details.
74 CertificateCredentials certificateCredentials = CertificateCredentials.cscCredentialBuilder()
75 .withProviderName(providerName)
76 .withCredentialID(credentialID)
77 .withPin(pin)
78 .withCSCAuthContext(cscAuthContext)
79 .build();
80
81 // Create parameters for the job
82 PDFElectronicSealParams pdfElectronicSealParams = PDFElectronicSealParams
83 .pdfElectronicSealParamsBuilder(certificateCredentials, fieldOptions)
84 .withDocumentLevelPermission(documentLevelPermission)
85 .withAppearanceOptions(appearanceOptions)
86 .build();
87
88 // Creates a new job instance
89 PDFElectronicSealJob pdfElectronicSealJob = new PDFElectronicSealJob(asset, pdfElectronicSealParams);
90 pdfElectronicSealJob.setSealImageAsset(sealImageAsset);
91
92 // Submit the job and gets the job result
93 String location = pdfServices.submit(pdfElectronicSealJob);
94 PDFServicesResponse<PDFElectronicSealResult> pdfServicesResponse = pdfServices.getJobResult(location, PDFElectronicSealResult.class);
95
96 // Get content from the resulting asset(s)
97 Asset resultAsset = pdfServicesResponse.getResult().getAsset();
98 StreamAsset streamAsset = pdfServices.getContent(resultAsset);
99
100 // Creates an output stream and copy stream asset's content to it
101 Files.createDirectories(Paths.get("output/"));
102 OutputStream outputStream = Files.newOutputStream(new File("output/sealedOutput.pdf").toPath());
103 LOGGER.info("Saving asset at output/sealedOutput.pdf");
104 IOUtils.copy(streamAsset.getInputStream(), outputStream);
105 outputStream.close();
106 } catch (ServiceApiException | IOException | SDKException | ServiceUsageException ex) {
107 LOGGER.error("Exception encountered while executing operation", ex);
108 }
109 }
110}
111

Apply Electronic Seal with trusted timestamp on PDF

The sample below performs electronic seal operation with a trusted timestamp on 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 ElectronicSealWithTimeStampAuthority {
8
9 // Initialize the logger.
10 private static final Logger LOGGER = LoggerFactory.getLogger(ElectronicSealWithTimeStampAuthority.class);
11
12 public static void main(String[] args) {
13 try (InputStream inputStream = Files.newInputStream(new File("src/main/resources/sampleInvoice.pdf").toPath());
14 InputStream inputStreamSealImage = Files.newInputStream(new File("src/main/resources/sampleSealImage.png").toPath())) {
15
16 // Initial setup, create credentials instance
17 Credentials credentials = new ServicePrincipalCredentials(
18 System.getenv("PDF_SERVICES_CLIENT_ID"),
19 System.getenv("PDF_SERVICES_CLIENT_SECRET"));
20
21 // Creates a PDF Services instance
22 PDFServices pdfServices = new PDFServices(credentials);
23
24 // Creates an asset(s) from source file(s) and upload
25 Asset asset = pdfServices.upload(inputStream, PDFServicesMediaType.PDF.getMediaType());
26 Asset sealImageAsset = pdfServices.upload(inputStreamSealImage, PDFServicesMediaType.PNG.getMediaType());
27
28 // Set the document level permission to be applied for output document
29 DocumentLevelPermission documentLevelPermission = DocumentLevelPermission.FORM_FILLING;
30
31 // Sets the Seal Field Name to be created in input PDF document.
32 String sealFieldName = "Signature1";
33
34 // Sets the page number in input document for applying seal.
35 Integer sealPageNumber = 1;
36
37 // Sets if seal should be visible or invisible.
38 Boolean sealVisible = true;
39
40 //Creates FieldLocation instance and set the coordinates for applying signature
41 FieldLocation fieldLocation = new FieldLocation(150, 250, 350, 200);
42
43 //Create FieldOptions instance with required details.
44 FieldOptions fieldOptions = new FieldOptions.Builder(sealFieldName)
45 .setFieldLocation(fieldLocation)
46 .setPageNumber(sealPageNumber)
47 .setVisible(sealVisible)
48 .build();
49
50 // Sets the name of TSP Provider being used.
51 String providerName = "<PROVIDER_NAME>";
52
53 // Sets the access token to be used to access TSP provider hosted APIs.
54 String accessToken = "<ACCESS_TOKEN>";
55
56 // Sets the credential ID.
57 String credentialID = "<CREDENTIAL_ID>";
58
59 // Sets the PIN generated while creating credentials.
60 String pin = "<PIN>";
61
62 //Creates CSCAuthContext instance using access token and token type.
63 CSCAuthContext cscAuthContext = new CSCAuthContext(accessToken, "Bearer");
64
65 //Create CertificateCredentials instance with required certificate details.
66 CertificateCredentials certificateCredentials = CertificateCredentials.cscCredentialBuilder()
67 .withProviderName(providerName)
68 .withCredentialID(credentialID)
69 .withPin(pin)
70 .withCSCAuthContext(cscAuthContext)
71 .build();
72
73 //Create TSABasicAuthCredentials using username and password
74 TSABasicAuthCredentials tsaBasicAuthCredentials = new TSABasicAuthCredentials("<USERNAME>", "<PASSWORD>");
75
76 // Set the Time Stamp Authority Options using url and TSA Auth credentials
77 TSAOptions tsaOptions = new RFC3161TSAOptions("<TIMESTAMP_URL>", tsaBasicAuthCredentials);
78
79 // Create parameters for the job
80 PDFElectronicSealParams pdfElectronicSealParams = PDFElectronicSealParams.pdfElectronicSealParamsBuilder(certificateCredentials, fieldOptions)
81 .withDocumentLevelPermission(documentLevelPermission)
82 .withTSAOptions(tsaOptions)
83 .build();
84
85 // Creates a new job instance
86 PDFElectronicSealJob pdfElectronicSealJob = new PDFElectronicSealJob(asset, pdfElectronicSealParams);
87
88 // Sets the optional input seal image for PDFElectronicSealOperation instance
89 pdfElectronicSealJob.setSealImageAsset(sealImageAsset);
90
91 // Submit the job and gets the job result
92 String location = pdfServices.submit(pdfElectronicSealJob);
93 PDFServicesResponse<PDFElectronicSealResult> pdfServicesResponse = pdfServices.getJobResult(location, PDFElectronicSealResult.class);
94
95 // Get content from the resulting asset(s)
96 Asset resultAsset = pdfServicesResponse.getResult().getAsset();
97 StreamAsset streamAsset = pdfServices.getContent(resultAsset);
98
99 // Creates an output stream and copy stream asset's content to it
100 Files.createDirectories(Paths.get("output/"));
101 OutputStream outputStream = Files.newOutputStream(new File("output/sealedOutput.pdf").toPath());
102 LOGGER.info("Saving asset at output/sealedOutput.pdf");
103 IOUtils.copy(streamAsset.getInputStream(), outputStream);
104 outputStream.close();
105 } catch (ServiceApiException | IOException | SDKException | ServiceUsageException ex) {
106 LOGGER.error("Exception encountered while executing operation", ex);
107 }
108 }
109}
110
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.