- 在AEM中安装DocuSign的API依赖项。
- 创建与DocuSign API和AEM集成的API应用程序。
- 使用Java编写自定义代码,实现AEM和DocuSign集成,并确保在AEM中可以通过API访问DocuSign电子签名。
下面是一个基本的Java代码示例,演示如何使用DocuSign API来创建一个新文档并将其发送给已指定的收件人进行签署:
// Create a new envelope with a document
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.setEmailSubject("Please sign this document");
envDef.setEmailBlurb("This document needs your signature");
// Read files from a local directory
byte[] fileBytes = Files.readAllBytes(Paths.get("/path/to/document.pdf"));
Bidning pdfDoc = new Document();
pdfDoc.setDocumentBase64(Base64.getEncoder().encodeToString(fileBytes));
pdfDoc.setName("Document.pdf");
pdfDoc.setFileExtension("pdf");
// Attach document and add recipient
Document[] docs = new Document[] { pdfDoc };
envDef.setDocuments(Arrays.asList(docs));
Signer signer = new Signer();
signer.setEmail("recipient@example.com");
signer.setName("Recipient");
signer.setRecipientId("1");
signer.setTabs(getTabs());
signer.setRoutingOrder("1");
// Add recipient and send envelope
envDef.setRecipients(new Recipients());
envDef.getRecipients().setSigners(Arrays.asList(signer));
envDef.setStatus("sent");
try {
ApiClient apiClient = new ApiClient();
apiClient.setBasePath("https://demo.docusign.net/restapi");
// Authenticate with DocuSign
DocuSignToken token = apiClient.requestJWTUserToken(CLIENT_ID, USER_GUID, "signature");
apiClient.setAccessToken(token.getAccessToken());
// Create envelope and send
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(ACCOUNT_ID, envDef);
} catch (ApiException ex) {
// Handle exception
}