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 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.
- DATE: Specifies that the sealing date/time should be displayed. This value should not be mistaken for a signed timestamp from a timestamp authority.
- DISTINGUISHED_NAME: Specifies that the distinguished name information from the digital certificate should be displayed.
- LABELS: Specifies that text labels should be displayed.
- SEAL_IMAGE: Specifies the seal image should be displayed.
- NAME: Specifies that the certificate owner's name should be displayed.
Example JSON
Copied to your clipboard1{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": 50023 }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 clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_java_samples2// Run the sample:3// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.electronicseal.ElectronicSeal45package com.adobe.pdfservices.operation.samples.electronicseal;67public class ElectronicSeal {89 // Initialize the logger.10 private static final Logger LOGGER = LoggerFactory.getLogger(ElectronicSeal.class);1112 public static void main(String[] args) {13 try {1415 // Initial setup, create credentials instance.16 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()17 .withClientId("PDF_SERVICES_CLIENT_ID")18 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")19 .build();2021 // Create an ExecutionContext using credentials.22 ExecutionContext executionContext = ExecutionContext.create(credentials);2324 //Get the input document to perform the sealing operation25 FileRef sourceFile = FileRef.createFromLocalFile("src/main/resources/sampleInvoice.pdf");2627 //Get the background seal image for signature , if required.28 FileRef sealImageFile = FileRef.createFromLocalFile("src/main/resources/sampleSealImage.png");2930 //Set the Seal Field Name to be created in input PDF document.31 String sealFieldName = "Signature1";3233 //Set the page number in input document for applying seal.34 Integer sealPageNumber = 1;3536 //Set if seal should be visible or invisible.37 Boolean sealVisible = true;3839 //Create FieldLocation instance and set the coordinates for applying signature40 FieldLocation fieldLocation = new FieldLocation(150, 250, 350, 200);4142 //Create FieldOptions instance with required details.43 FieldOptions fieldOptions = new FieldOptions.Builder(sealFieldName)44 .setFieldLocation(fieldLocation)45 .setPageNumber(sealPageNumber)46 .setVisible(sealVisible)47 .build();4849 //Set the name of TSP Provider being used.50 String providerName = "<PROVIDER_NAME>";5152 //Set the access token to be used to access TSP provider hosted APIs.53 String accessToken = "<ACCESS_TOKEN>";5455 //Set the credential ID.56 String credentialID = "<CREDENTIAL_ID>";5758 //Set the PIN generated while creating credentials.59 String pin = "<PIN>";6061 //Create CSCAuthContext instance using access token and token type.62 CSCAuthContext cscAuthContext = new CSCAuthContext(accessToken, "Bearer");6364 //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();7172 //Create SealOptions instance with sealing parameters.73 SealOptions sealOptions = new SealOptions.Builder(certificateCredentials, fieldOptions).build();7475 //Create the PDFElectronicSealOperation instance using the SealOptions instance76 PDFElectronicSealOperation pdfElectronicSealOperation = PDFElectronicSealOperation.createNew(sealOptions);7778 //Set the input source file for PDFElectronicSealOperation instance79 pdfElectronicSealOperation.setInput(sourceFile);8081 //Set the optional input seal image for PDFElectronicSealOperation instance82 pdfElectronicSealOperation.setSealImage(sealImageFile);8384 //Execute the operation85 FileRef result = pdfElectronicSealOperation.execute(executionContext);8687 //Save the output at specified location88 result.saveAs("output/sealedOutput.pdf");899091 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {92 LOGGER.error("Exception encountered while executing operation", ex);93 }94 }95}96
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd ElectronicSeal/4// dotnet run ElectronicSeal.csproj56namespace ElectronicSeal7{8 class Program9 {10 // Initialize the logger.11 private static readonly ILog log = LogManager.GetLogger(typeof(Program));12 static void Main()13 {14 //Configure the logging15 ConfigureLogging();1617 try18 {19 // Initial setup, create credentials instance.20 Credentials credentials = Credentials.ServicePrincipalCredentialsBuilder()21 .WithClientId("PDF_SERVICES_CLIENT_ID")22 .WithClientSecret("PDF_SERVICES_CLIENT_SECRET")23 .Build();2425 // Create an ExecutionContext using credentials.26 ExecutionContext executionContext = ExecutionContext.Create(credentials);2728 //Set the input document to perform the sealing operation29 FileRef sourceFile = FileRef.CreateFromLocalFile(@"SampleInvoice.pdf");3031 //Set the background seal image for signature , if required.32 FileRef sealImageFile = FileRef.CreateFromLocalFile(@"sampleSealImage.png");3334 //Set the Seal Field Name to be created in input PDF document.35 string sealFieldName = "Signature1";3637 //Set the page number in input document for applying seal.38 int sealPageNumber = 1;3940 //Set if seal should be visible or invisible.41 bool sealVisible = true;4243 //Create FieldLocation instance and set the coordinates for applying signature44 FieldLocation fieldLocation = new FieldLocation(150, 250, 350, 200);4546 //Create FieldOptions instance with required details.47 FieldOptions sealFieldOptions = new FieldOptions.Builder(sealFieldName)48 .SetVisible(sealVisible)49 .SetFieldLocation(fieldLocation)50 .SetPageNumber(sealPageNumber)51 .Build();5253 //Set the name of TSP Provider being used.54 string providerName = "<PROVIDER_NAME>";5556 //Set the access token to be used to access TSP provider hosted APIs.57 string accessToken = "<ACCESS_TOKEN>";5859 //Set the credential ID.60 string credentialID = "<CREDENTIAL_ID>";6162 //Set the PIN generated while creating credentials.63 string pin = "<PIN>";6465 CSCAuthContext cscAuthContext = new CSCAuthContext(accessToken, "Bearer");6667 //Create CertificateCredentials instance with required certificate details.68 CertificateCredentials certificateCredentials = CertificateCredentials.CSCCredentialBuilder()69 .WithProviderName(providerName)70 .WithCredentialID(credentialID)71 .WithPin(pin)72 .WithCSCAuthContext(cscAuthContext)73 .Build();7475 //Create SealingOptions instance with all the sealing parameters.76 SealOptions sealOptions = new SealOptions.Builder(certificateCredentials, sealFieldOptions).Build();7778 //Create the PDFElectronicSealOperation instance using the PDFElectronicSealOptions instance79 PDFElectronicSealOperation pdfElectronicSealOperation = PDFElectronicSealOperation.CreateNew(sealOptions);8081 //Set the input source file for PDFElectronicSealOperation instance82 pdfElectronicSealOperation.SetInput(sourceFile);8384 //Set the optional input seal image for PDFElectronicSealOperation instance85 pdfElectronicSealOperation.SetSealImage(sealImageFile);8687 //Execute the operation88 FileRef result = pdfElectronicSealOperation.Execute(executionContext);8990 // Save the output at specified location.91 result.SaveAs(output/sealedOutput.pdf);92 }93 catch (ServiceUsageException ex)94 {95 log.Error("Exception encountered while executing operation", ex);96 }97 catch (ServiceApiException ex)98 {99 log.Error("Exception encountered while executing operation", ex);100 }101 catch (SDKException ex)102 {103 log.Error("Exception encountered while executing operation", ex);104 }105 catch (IOException ex)106 {107 log.Error("Exception encountered while executing operation", ex);108 }109 catch (Exception ex)110 {111 log.Error("Exception encountered while executing operation", ex);112 }113114 }115 static void ConfigureLogging()116 {117 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());118 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));119 }120 }121}
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/electronicseal/electronic-seal.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials);1718 const pdfElectronicSeal = PDFServicesSdk.PDFElectronicSeal,19 options = pdfElectronicSeal.options;2021 //Get the input document to perform the sealing operation22 const sourceFile = PDFServicesSdk.FileRef.createFromLocalFile('resources/sampleInvoice.pdf'),2324 //Get the background seal image for signature , if required.25 sealImageFile = PDFServicesSdk.FileRef.createFromLocalFile('resources/sampleSealImage.png');2627 // Set the Seal Field Name to be created in input PDF document.28 sealFieldName = "Signature1";2930 // Set the page number in input document for applying seal.31 sealPageNumber = 1;3233 // Set if seal should be visible or invisible.34 sealVisible = true;3536 //Create FieldLocation instance and set the coordinates for applying signature37 fieldLocation = new options.FieldLocation(150,250,350,200);3839 //Create FieldOptions instance with required details.40 fieldOptions = new options.FieldOptions.Builder(sealFieldName)41 .setFieldLocation(fieldLocation)42 .setPageNumber(sealPageNumber)43 .setVisible(sealVisible)44 .build();4546 //Set the name of TSP Provider being used.47 providerName = "<PROVIDER_NAME>";4849 //Set the access token to be used to access TSP provider hosted APIs.50 accessToken = "<ACCESS_TOKEN>";5152 //Set the credential ID.53 credentialID = "<CREDENTIAL_ID>";5455 //Set the PIN generated while creating credentials.56 pin = "<PIN>";5758 //Create CSCAuthContext instance using access token and token type.59 cscAuthContext = new options.CSCAuthContext(accessToken, "Bearer");6061 //Create CertificateCredentials instance with required certificate details.62 certificateCredentials = options.CertificateCredentials.cscCredentialBuilder()63 .withProviderName(providerName)64 .withCredentialID(credentialID)65 .withPin(pin)66 .withCSCAuthContext(cscAuthContext)67 .build();6869 //Create SealOptions instance with sealing parameters.70 sealOptions = new options.SealOptions.Builder(certificateCredentials, fieldOptions)71 .build()7273 //Create the PDFElectronicSealOperation instance using the SealOptions instance74 const pdfElectronicSealOperation = pdfElectronicSeal.Operation.createNew(sealOptions);7576 //Set the input source file for PDFElectronicSealOperation instance77 pdfElectronicSealOperation.setInput(sourceFile);7879 //Set the optional input seal image for PDFElectronicSealOperation instance80 pdfElectronicSealOperation.setSealImage(sealImageFile);8182 // Execute the operation and Save the result to the specified location.83 pdfElectronicSealOperation.execute(executionContext)84 .then(result => result.saveAsFile("output/sealedOutput.pdf"))85 .catch(err => {86 if(err instanceof PDFServicesSdk.Error.ServiceApiError87 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {88 console.log('Exception encountered while executing operation', err);89 } else {90 console.log('Exception encountered while executing operation', err);91 }92 });9394 } catch (err) {95 console.log('Exception encountered while executing operation', err);96}
Copied to your clipboard1curl --location --request POST 'https://pdf-services.adobe.io/operation/electronicseal' \2--header 'x-api-key: {{Placeholder for client_id}}' \3--header 'Content-Type: application/json' \4--header 'Authorization: Bearer {{Placeholder for token}}' \5--data-raw '{6 "inputDocumentAssetID": "urn:aaid:AS:UE1:23c30ee0-2c4d-xxxx-xxxx-087832fca718",7 "sealImageAssetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-xxxx-xxxx-087832fca718",8 "sealOptions": {9 "signatureFormat": "PKCS7",10 "cscCredentialOptions": {11 "credentialId": "<CREDENTIAL_ID>",12 "providerName": "<PROVIDER_NAME>",13 "authorizationContext": {14 "tokenType": "Bearer",15 "accessToken": "<ACCESS_TOKEN>"16 },17 "credentialAuthParameters": {18 "pin": "<PIN>"19 }20 },21 "sealFieldOptions": {22 "location": {23 "top": 300,24 "left": 50,25 "right": 250,26 "bottom": 10027 },28 "fieldName": "Signature1",29 "pageNumber": 130 }31 }32}'
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 clipboard1// Get the samples from https://github.com/adobe/pdfservices-java-sdk-samples/tree/beta2// Run the sample:3// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.electronicseal.ElectronicSealWithAppearanceOptions45package com.adobe.pdfservices.operation.samples.electronicseal;67public class ElectronicSealWithAppearanceOptions {89 // Initialize the logger.10 private static final Logger LOGGER = LoggerFactory.getLogger(ElectronicSeal.class);1112 public static void main(String[] args) {13 try {1415 // Initial setup, create credentials instance.16 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()17 .withClientId("PDF_SERVICES_CLIENT_ID")18 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")19 .build();2021 // Create an ExecutionContext using credentials.22 ExecutionContext executionContext = ExecutionContext.create(credentials);2324 //Get the input document to perform the sealing operation25 FileRef sourceFile = FileRef.createFromLocalFile("src/main/resources/sampleInvoice.pdf");2627 //Get the background seal image for signature , if required.28 FileRef sealImageFile = FileRef.createFromLocalFile("src/main/resources/sampleSealImage.png");2930 //Create AppearanceOptions and add the required signature display items to it31 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);3738 //Set the Seal Field Name to be created in input PDF document.39 String sealFieldName = "Signature1";4041 //Set the page number in input document for applying seal.42 Integer sealPageNumber = 1;4344 //Set if seal should be visible or invisible.45 Boolean sealVisible = true;4647 //Create FieldLocation instance and set the coordinates for applying signature48 FieldLocation fieldLocation = new FieldLocation(150, 250, 350, 200);4950 //Create FieldOptions instance with required details.51 FieldOptions fieldOptions = new FieldOptions.Builder(sealFieldName)52 .setFieldLocation(fieldLocation)53 .setPageNumber(sealPageNumber)54 .setVisible(sealVisible)55 .build();5657 //Set the name of TSP Provider being used.58 String providerName = "<PROVIDER_NAME>";5960 //Set the access token to be used to access TSP provider hosted APIs.61 String accessToken = "<ACCESS_TOKEN>";6263 //Set the credential ID.64 String credentialID = "<CREDENTIAL_ID>";6566 //Set the PIN generated while creating credentials.67 String pin = "<PIN>";6869 //Create CSCAuthContext instance using access token and token type.70 CSCAuthContext cscAuthContext = new CSCAuthContext(accessToken, "Bearer");7172 //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();7980 //Create SealOptions instance with all the sealing parameters.81 SealOptions sealOptions = new SealOptions.Builder(certificateCredentials, fieldOptions)82 .withAppearanceOptions(appearanceOptions).build();8384 //Create the PDFElectronicSealOperation instance using the SealOptions instance85 PDFElectronicSealOperation pdfElectronicSealOperation = PDFElectronicSealOperation.createNew(sealOptions);8687 //Set the input source file for PDFElectronicSealOperation instance88 pdfElectronicSealOperation.setInput(sourceFile);8990 //Set the optional input seal image for PDFElectronicSealOperation instance91 pdfElectronicSealOperation.setSealImage(sealImageFile);9293 //Execute the operation94 FileRef result = pdfElectronicSealOperation.execute(executionContext);9596 //Save the output at specified location97 result.saveAs("output/sealedOutput.pdf");9899100 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {101 LOGGER.error("Exception encountered while executing operation", ex);102 }103 }104}105
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd ElectronicSealWithAppearanceOptions/4// dotnet run ElectronicSealWithAppearanceOptions.csproj56namespace ElectronicSealWithAppearanceOptions7{8 class Program9 {10 // Initialize the logger.11 private static readonly ILog log = LogManager.GetLogger(typeof(Program));12 static void Main()13 {14 //Configure the logging15 ConfigureLogging();1617 try18 {19 // Initial setup, create credentials instance.20 Credentials credentials = Credentials.ServicePrincipalCredentialsBuilder()21 .WithClientId("PDF_SERVICES_CLIENT_ID")22 .WithClientSecret("PDF_SERVICES_CLIENT_SECRET")23 .Build();242526 // Create an ExecutionContext using credentials.27 ExecutionContext executionContext = ExecutionContext.Create(credentials);2829 //Set the input document to perform the sealing operation30 FileRef sourceFile = FileRef.CreateFromLocalFile(@"SampleInvoice.pdf");3132 //Set the background seal image for signature , if required.33 FileRef sealImageFile = FileRef.CreateFromLocalFile(@"sampleSealImage.png");3435 //Create AppearanceOptions and add the required signature appearance items36 AppearanceOptions appearanceOptions = new AppearanceOptions();37 appearanceOptions.AddItem(AppearanceItem.NAME);38 appearanceOptions.AddItem(AppearanceItem.LABELS);39 appearanceOptions.AddItem(AppearanceItem.DATE);40 appearanceOptions.AddItem(AppearanceItem.SEAL_IMAGE);41 appearanceOptions.AddItem(AppearanceItem.DISTINGUISHED_NAME);4243 //Set the Seal Field Name to be created in input PDF document.44 string sealFieldName = "Signature1";4546 //Set the page number in input document for applying seal.47 int sealPageNumber = 1;4849 //Set if seal should be visible or invisible.50 bool sealVisible = true;5152 //Create FieldLocation instance and set the coordinates for applying signature53 FieldLocation fieldLocation = new FieldLocation(150, 250, 350, 200);5455 //Create FieldOptions instance with required details.56 FieldOptions fieldOptions = new FieldOptions.Builder(sealFieldName)57 .SetVisible(sealVisible)58 .SetFieldLocation(fieldLocation)59 .SetPageNumber(sealPageNumber)60 .Build();6162 //Set the name of TSP Provider being used.63 string providerName = "<PROVIDER_NAME>";6465 //Set the access token to be used to access TSP provider hosted APIs.66 string accessToken = "<ACCESS_TOKEN>";6768 //Set the credential ID.69 string credentialID = "<CREDENTIAL_ID>";7071 //Set the PIN generated while creating credentials.72 string pin = "<PIN>";7374 CSCAuthContext cscAuthContext = new CSCAuthContext(accessToken, "Bearer");7576 //Create CertificateCredentials instance with required certificate details.77 CertificateCredentials certificateCredentials = CertificateCredentials.CSCCredentialBuilder()78 .WithProviderName(providerName)79 .WithCredentialID(credentialID)80 .WithPin(pin)81 .WithCSCAuthContext(cscAuthContext)82 .Build();838485 //Create SealingOptions instance with all the sealing parameters.86 SealOptions sealOptions = new SealOptions.Builder(certificateCredentials, fieldOptions)87 .WithAppearanceOptions(appearanceOptions).Build();8889 //Create the PDFElectronicSealOperation instance using the SealOptions instance90 PDFElectronicSealOperation pdfElectronicSealOperation = PDFElectronicSealOperation.CreateNew(sealOptions);9192 //Set the input source file for PDFElectronicSealOperation instance93 pdfElectronicSealOperation.SetInput(sourceFile);9495 //Set the optional input seal image for PDFElectronicSealOperation instance96 pdfElectronicSealOperation.SetSealImage(sealImageFile);9798 //Execute the operation99 FileRef result = pdfElectronicSealOperation.Execute(executionContext);100101 // Save the output at specified location.102 result.SaveAs(output/sealedOutput.pdf);103 }104 catch (ServiceUsageException ex)105 {106 log.Error("Exception encountered while executing operation", ex);107 }108 catch (ServiceApiException ex)109 {110 log.Error("Exception encountered while executing operation", ex);111 }112 catch (SDKException ex)113 {114 log.Error("Exception encountered while executing operation", ex);115 }116 catch (IOException ex)117 {118 log.Error("Exception encountered while executing operation", ex);119 }120 catch (Exception ex)121 {122 log.Error("Exception encountered while executing operation", ex);123 }124125 }126 static void ConfigureLogging()127 {128 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());129 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));130 }131 }132}
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/electronicseal/electronic-seal.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials);1718 const pdfElectronicSeal = PDFServicesSdk.PDFElectronicSeal,19 options = pdfElectronicSeal.options;2021 //Get the input document to perform the sealing operation22 const sourceFile = PDFServicesSdk.FileRef.createFromLocalFile('resources/sampleInvoice.pdf'),2324 //Get the background seal image for signature , if required.25 sealImageFile = PDFServicesSdk.FileRef.createFromLocalFile('resources/sampleSealImage.png');2627 //Create AppearanceOptions and add the required signature appearance items28 appearanceOptions = new options.AppearanceOptions();29 appearanceOptions.addItem(options.AppearanceOptions.AppearanceItem.DATE);30 appearanceOptions.addItem(options.AppearanceOptions.AppearanceItem.SEAL_IMAGE);31 appearanceOptions.addItem(options.AppearanceOptions.AppearanceItem.NAME);32 appearanceOptions.addItem(options.AppearanceOptions.AppearanceItem.LABELS);33 appearanceOptions.addItem(options.AppearanceOptions.AppearanceItem.DISTINGUISHED_NAME);3435 // Set the Seal Field Name to be created in input PDF document.36 sealFieldName = "Signature1";3738 // Set the page number in input document for applying seal.39 sealPageNumber = 1;4041 // Set if seal should be visible or invisible.42 sealVisible = true;4344 //Create FieldLocation instance and set the coordinates for applying signature45 fieldLocation = new options.FieldLocation(150,250,350,200);4647 //Create FieldOptions instance with required details.48 fieldOptions = new options.FieldOptions.Builder(sealFieldName)49 .setFieldLocation(fieldLocation)50 .setPageNumber(sealPageNumber)51 .setVisible(sealVisible)52 .build();5354 //Set the name of TSP Provider being used.55 providerName = "<PROVIDER_NAME>";5657 //Set the access token to be used to access TSP provider hosted APIs.58 accessToken = "<ACCESS_TOKEN>";5960 //Set the credential ID.61 credentialID = "<CREDENTIAL_ID>";6263 //Set the PIN generated while creating credentials.64 pin = "<PIN>";6566 //Create CSCAuthContext instance using access token and token type.67 cscAuthContext = new options.CSCAuthContext(accessToken, "Bearer");6869 //Create CertificateCredentials instance with required certificate details.70 certificateCredentials = options.CertificateCredentials.cscCredentialBuilder()71 .withProviderName(providerName)72 .withCredentialID(credentialID)73 .withPin(pin)74 .withCSCAuthContext(cscAuthContext)75 .build();7677 //Create SealOptions instance with sealing parameters.78 sealOptions = new options.SealOptions.Builder(certificateCredentials, fieldOptions)79 .withAppearanceOptions(appearanceOptions)80 .build()8182 //Create the PDFElectronicSealOperation instance using the SealOptions instance83 const pdfElectronicSealOperation = pdfElectronicSeal.Operation.createNew(sealOptions);8485 //Set the input source file for PDFElectronicSealOperation instance86 pdfElectronicSealOperation.setInput(sourceFile);8788 //Set the optional input seal image for PDFElectronicSealOperation instance89 pdfElectronicSealOperation.setSealImage(sealImageFile);9091 // Execute the operation and Save the result to the specified location.92 pdfElectronicSealOperation.execute(executionContext)93 .then(result => result.saveAsFile("output/sealedOutput.pdf"))94 .catch(err => {95 if(err instanceof PDFServicesSdk.Error.ServiceApiError96 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {97 console.log('Exception encountered while executing operation', err);98 } else {99 console.log('Exception encountered while executing operation', err);100 }101 });102103 } catch (err) {104 console.log('Exception encountered while executing operation', err);105}
Copied to your clipboard1curl --location --request POST 'https://pdf-services.adobe.io/operation/electronicseal' \2--header 'x-api-key: {{Placeholder for client_id}}' \3--header 'Content-Type: application/json' \4--header 'Authorization: Bearer {{Placeholder for token}}' \5--data-raw '{6 "inputDocumentAssetID": "urn:aaid:AS:UE1:23c30ee0-2c4d-xxxx-xxxx-087832fca718",7 "sealImageAssetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-xxxx-xxxx-087832fca718",8 "sealOptions": {9 "signatureFormat": "PKCS7",10 "cscCredentialOptions": {11 "credentialId": "<CREDENTIAL_ID>",12 "providerName": "<PROVIDER_NAME>",13 "authorizationContext": {14 "tokenType": "Bearer",15 "accessToken": "<ACCESS_TOKEN>"16 },17 "credentialAuthParameters": {18 "pin": "<PIN>"19 }20 },21 "sealFieldOptions": {22 "location": {23 "top": 300,24 "left": 50,25 "right": 250,26 "bottom": 10027 },28 "fieldName": "Signature1",29 "pageNumber": 130 },31 "sealAppearanceOptions": {32 "displayOptions": [33 "NAME",34 "DATE",35 "DISTINGUISHED_NAME",36 "LABELS",37 "SEAL_IMAGE"38 ]39 }40 }41}'