Spire.Cloud.Word provides the DigitalSignatureApi interface to add digital signature to Word. This tutorial will introduce how to do it using Java codes.
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.DigitalSignatureApi;
import java.io.File;
public class DigitalSignature {
static String appId = "App ID";
static String appKey = "App Key";
static String baseUrl = "https://api.cloudxdocs.com";
//Create a Configuration object based on your App ID and App Key
static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
//Initialize the DigitalSignatureApi object
static DigitalSignatureApi digitalsignatureApi = new DigitalSignatureApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
//Load a Word document
String name = "Sample.docx";
//Load a .pfx file to add digital signature
File pfxFile = new File("C:\\Users\\Test1\\Desktop\\gary.pfx");
//Set a password
String pfxFilePassword = "e-iceblue";
//Specify the folder storing the sample, it’s null if nothing
String folder = "input";
//Use the 2G storage provided by E-iceblue Cloud, it’s null by default
String storage = null;
//Specify the password used to open the sample, it's null if nothing
String docPassword = null;
//Specify the path of the resulting document
String destFilePath = "output/addDigitalSignature.docx";
//Call the addDigitalSignature method to add digital signature to Word
digitalsignatureApi.addDigitalSignature(name, pfxFile, pfxFilePassword, destFilePath, folder, storage, docPassword);
}
}
Output