【发布时间】:2019-03-25 16:52:34
【问题描述】:
我们正在使用来自 REST API 的 Java 库开发一个对多个文档进行签名的过程,其中签名位置是使用 signHereTabs 中的anchorString 为每个签名者设置的(anchorString 是插入到要签名的文档中的字符串); 由于我们有大于 25MB 的文档,我们正在使用 https://developers.docusign.com/esign-rest-api/guides/resource-limits 中报告的内容,即我们创建一个草稿信封 (status=created),然后我们使用文档更新信封; 问题是当我们设置状态=已发送的信封时,签名者收到电子邮件,打开DocuSign的链接,但只有第一个文档允许访问anchorString。 有什么特别的方法可以更新草稿信封中的文件列表吗?
谢谢
...
// add a recipient to sign the document, identified by name and email we used above
int recipientId = 0;
List<Signer> signerList = new ArrayList<Signer>();
/* to fix the position where the signature has to be inserted */
int buyerIdx = 0;
int supplierIdx = 0;
for(DSSignerInfo signerInfo : signers) {
Tabs tabs = new Tabs();
Signer signer = new Signer();
signer.setEmail(signerInfo.getEmail());
signer.setName(signerInfo.getName());
signer.setRecipientId(String.valueOf(++recipientId));
signer.setRoutingOrder(String.valueOf(recipientId)); // sequential
signer.setRoleName("role unknown");
RecipientEmailNotification emailNotification = new RecipientEmailNotification();
emailNotification.setEmailBody("emailBody - "+signerInfo.getName());
emailNotification.setEmailSubject("emailSubject - "+signerInfo.getName());
emailNotification.setSupportedLanguage(signerInfo.getLanguage());
signer.setEmailNotification(emailNotification);
// create a signHere tab somewhere on the document for the signer to sign
// default unit of measurement is pixels, can be mms, cms, inches also
for(int documentId = 1; documentId <= documentFiles.size(); documentId++) {
SignHere signHere = new SignHere();
signHere.setDocumentId("" + documentId);
signHere.setPageNumber("1");
signHere.setRecipientId(String.valueOf(recipientId));
if(signerInfo.getRole().equalsIgnoreCase("buyer")) {
signHere.setAnchorString("BUYER_"+buyerIdx);
} else {
signHere.setAnchorString("SUPPLIER_"+supplierIdx);
}
signHere.setAnchorXOffset("10");
signHere.setAnchorYOffset("10");
tabs.addSignHereTabsItem(signHere);
}
signer.setTabs(tabs);
signerList.add(signer);
if(signerInfo.getRole().equalsIgnoreCase("buyer")) {
buyerIdx++;
} else {
supplierIdx++;
}
}
Recipients recipients = new Recipients();
recipients.setSigners(signerList);
envDef.setRecipients(recipients);
try {
String envelopeId = null;
EnvelopesApi envelopesApi = null;
// create a byte array that will hold our document bytes
int documentId = 1;
for(String documentFile : documentFiles) {
byte[] fileBytes = null;
try {
// read file
Path path = Paths.get(documentFile);
fileBytes = Files.readAllBytes(path);
} catch (IOException ioExcp) {
// handle error
System.out.println("Exception: " + ioExcp);
return null;
}
// add a document to the envelope
Document doc = new Document();
String base64Doc = Base64.getEncoder().encodeToString(fileBytes);
doc.setDocumentBase64(base64Doc);
String fileName = new File(documentFile).getName();
doc.setName(documentId+"_"+fileName);
doc.setFileExtension(fileName.lastIndexOf('.') > 0 ? fileName.substring(fileName.lastIndexOf('.') + 1) : "");
doc.setDocumentId("" + documentId++);
envDef.addDocumentsItem(doc);
if(envelopeId == null || envelopesApi == null) {
// To save as a draft set to "created" (for test purpose I create and envelope with only one file)
envDef.setStatus("created");
envelopesApi = new EnvelopesApi();
EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envDef);
envelopeId = envelopeSummary.getEnvelopeId();
} else {
// the files after the 1st are updated in the draft envelope
envDef.setRecipients(recipients);
List<Document> tmpDocumentList = new ArrayList<Document>();
doc.setApplyAnchorTabs("true");
tmpDocumentList.add(doc);
envDef.setDocuments(tmpDocumentList);
EnvelopeDocumentsResult envelopeDocumentsResult = envelopesApi.updateDocuments(accountId, envelopeId, envDef);
}
}
Envelope envelope = envelopesApi.getEnvelope(accountId, envelopeId);
envelope.setStatus("sent");
envelope.setPurgeState(null);
EnvelopesApi.UpdateOptions uo = envelopesApi. new UpdateOptions();
uo.setAdvancedUpdate("true");
EnvelopeUpdateSummary envelopeUpdateSummary = envelopesApi.update(accountId, envelopeId, envelope, uo);
documentId = 1;
for(String documentFile : documentFiles) {
Tabs tabs = envelopesApi.getDocumentTabs(accountId, envelopeId, ""+documentId++);
System.out.println("CARLO Tabs 3, documentId "+(documentId - 1)+": "+tabs);
}
感谢您的回答。 更多细节: 在信封里我们有不止一份文件; 每个文档的大小小于 25MB; 所有文档的大小总和超过 25MB。 我们可以将状态为“已创建”的文件上传到信封中,但是当状态更改为“已发送”并且签名者进入签名页面时,则不需要对这些文件进行签名;似乎在信封状态为“已创建”时添加的文档中未设置 signHereTabs。
如果在设置信封状态 = "sent" 后我们执行以下代码
documentId = 1;
for(String documentFile : documentFiles) {
Tabs tabs = envelopesApi.getDocumentTabs(accountId, envelopeId, ""+documentId++);
System.out.println("Tabs: documentId "+(documentId - 1)+": "+tabs);
}
我们得到
标签:documentId 1:类标签{ ... signHereTabs: [类 SignHere { 锚点敏感:空 锚水平对齐:空 锚点IgnoreIfNotPresent:空 锚匹配WholeWord:空 锚字符串:BUYER_0 锚点单位:像素 锚点偏移:10 锚点偏移:-10 条件父标签:空 条件父值:空 customTabId:空 文档编号:1 错误详细信息:空 合并字段:空 名称:SignHere 可选:假 页码:1 收件人 ID:edb96dfd-9700-4328-ba45-825a1284b030 比例值:1.0 邮票类型:签名 邮票类型元数据:空 状态:空 tabId:e484087c-70c2-431c-9825-47605e1f44c2 tabLabel:在此签名 选项卡顺序:空 模板锁定:空 模板必填:空 工具提示:空 x位置:123 y位置:297 }] ... } 选项卡:documentId 2:类选项卡 { ... 签到标签:[] ... }
在创建信封时已上传 documentId 1 (status="created"),并且在第二步中已上传 documentId 2(documentId 1 和 2 都包含锚字符串:BUYER_0)。
【问题讨论】:
-
欢迎来到 StackOverflow,感谢您使用 DocuSign!请为所有有用的答案投票,包括对他人问题的回答。请检查(接受)您自己问题的最佳答案。谢谢。
-
请看我更新的答案。
标签: docusignapi