关于通过DocuSign Java API实现无Tabs信封预览后设签名域再发送的可行性咨询
Absolutely, this workflow is fully supported by the DocuSign Java API! You can create a draft envelope with your document (no pre-configured signature tabs), generate a preview link to let you add signature fields manually, then send the envelope once everything’s set up. Here’s how to do it:
Step 1: Create a Draft Envelope Without Signature Tabs
First, you’ll create an envelope in created status (draft mode) with your document and recipient details, but skip adding any signHere or other signature-related tabs. This keeps the envelope blank and ready for manual setup in the preview.
// Initialize the DocuSign client (ensure your auth setup is complete) ApiClient apiClient = new ApiClient(basePath); apiClient.setAccessToken(accessToken); EnvelopesApi envelopesApi = new EnvelopesApi(apiClient); // Define the envelope EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition(); envelopeDefinition.setEmailSubject("Please sign this document"); envelopeDefinition.setStatus("created"); // Critical: keeps the envelope as a draft // Add your target document Document document = new Document(); document.setDocumentBase64(Base64.getEncoder().encodeToString(Files.readAllBytes(Paths.get("path/to/your/new-document.pdf")))); document.setName("Document to Sign"); document.setDocumentId("1"); envelopeDefinition.setDocuments(Arrays.asList(document)); // Add the signer recipient Signer signer = new Signer(); signer.setEmail("recipient-email@example.com"); signer.setName("Recipient Full Name"); signer.setRecipientId("1"); Recipients recipients = new Recipients(); recipients.setSigners(Arrays.asList(signer)); envelopeDefinition.setRecipients(recipients); // Create the draft envelope EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envelopeDefinition); String envelopeId = envelopeSummary.getEnvelopeId();
Step 2: Generate a Preview URL for Manual Tab Setup
Next, generate a preview link that opens the draft envelope in DocuSign’s web interface, where you can drag-and-drop signature fields (and other tabs like initials, date, etc.) onto your document.
// Build the preview request EnvelopePreviewRequest previewRequest = new EnvelopePreviewRequest(); previewRequest.setReturnUrl("https://your-app-domain.com/preview-complete"); // Redirect back to your app after preview previewRequest.setRecipientId("1"); // Match the recipient ID from step 1 previewRequest.setEmail("recipient-email@example.com"); previewRequest.setUserName("Recipient Full Name"); // Fetch the preview URL EnvelopePreview envelopePreview = envelopesApi.createEnvelopePreview(accountId, envelopeId, previewRequest); String previewUrl = envelopePreview.getUrl();
Redirect yourself to this previewUrl—once in the DocuSign preview interface, you can add all necessary signature and form fields directly on the document.
Step 3: Send the Envelope After Setup
Once you’ve added all required tabs in the preview, you have two ways to send the envelope:
- You can click the "Send" button directly within the DocuSign preview interface.
- Or, use the API to update the envelope status to
sentprogrammatically:
// Update envelope status to trigger sending EnvelopeDefinition updateEnvelope = new EnvelopeDefinition(); updateEnvelope.setStatus("sent"); envelopesApi.update(accountId, envelopeId, updateEnvelope);
This will send the signature request to your specified recipient immediately.
内容的提问来源于stack exchange,提问作者rivar_

