将文档添加到草稿信封中,不带符号HereTabs



我们正在开发一个来自 REST API 的 Java 库来签署多个文档的过程,其中签名位置是在每个签名者的 signHereTabs 中使用 anchorString 设置的(anchorString 是插入到要签名的文档中的字符串); 由于我们有大小大于 25MB 的文档,因此我们使用 https://developers.docusign.com/esign-rest-api/guides/resource-limits 中报告的内容 ,即我们创建一个草稿信封(状态=已创建),然后我们用文档更新信封; 问题是,当我们设置状态=已发送的信封时,签名者会收到电子邮件,打开指向DocuSign的链接,但只有第一个文档允许访问锚字符串。 是否有任何特殊方法可以更新信封草稿中的文件列表?

谢谢

// 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。

如果在设置信封状态 = "已发送" 后,我们执行以下代码

documentId = 1;
for(String documentFile : documentFiles) {
Tabs tabs = envelopesApi.getDocumentTabs(accountId, envelopeId, ""+documentId++);
System.out.println("Tabs: documentId "+(documentId - 1)+": "+tabs);
}

我们获得

制表符:文档 ID 1:类制表符 { ... signHereTabs: [class SignHere { 锚区分大小写:空 锚点水平对齐方式:空 anchorIgnoreIfNotPresent: null anchorMatchWholeWord: null 锚字符串:BUYER_0 锚单位:像素 锚点XOffset:10 锚点:-10 conditionalParentLabel: null conditionalParentValue: null customTabId: null 文档 ID: 1 错误详细信息:空 合并字段:空 名称: 在这里登录 可选:假 页码: 1 收件人 ID: edb96dfd-9700-4328-ba45-825a1284b030 比例值:1.0 邮票类型:签名 stampType元数据:空 状态:空 标签标识: e484087c-70c2-431c-9825-47605e1f44c2 标签:在此签名 选项卡顺序:空 模板已锁定:空 模板必需:空 工具提示:空 x位置: 123 y位置: 297 }] ... } 选项卡:文档 ID 2:类选项卡 { ... 在这里签名选项卡: [] ... }

其中,在创建信封时已上载 documentId 1(status="created"),文档 ID 2 已在第二步中上载(documentId 1 和 2 都包含锚字符串:BUYER_0)。

如果您的文档大小大于 25MB,那么将文档置于草稿模式也无济于事,相反,您必须使用 ChunkedUploads 添加任何小于 50MB 的文档。如果您的 JSON 请求有效负载大于 25 MB,则通过草稿添加多个文档很有用,但如果信封中的任何文档大于 25 MB,则不会有用。

为了补充Amit的答案,每个对DocuSign的API请求必须小于25MB。

由于默认技术是在 JSON 对象中发送 Base64 编码的文档,因此在单个请求中发送的所有文档的有效最大总大小约为 18MB。

您可以通过将 API 请求作为多部分 MIME 消息发送来避免 Base64 开销。此技术使您能够将文档作为二进制对象发送。请参阅 C# 中方案 10 的代码示例(也可用于 PHP、Java、Node.js、Python 和 Ruby)

附加

如果每个文档小于 18 MB,则可以使用"常规"JSON 对象,一次对一个文档进行 Base64 编码。如果文档大小的总和大于 18MB,则必须一次上传一个:

  1. 创建信封,包括其中一个文档。文档状态应created,以便此时不发送信封。
  2. 向信封添加更多文档,一次添加一个。您可以使用 EnvelopeDocuments::updateList API 方法。您可能希望查询参数apply_document_fields
  3. 使用信封更新信封状态为sent:更新

要向文档添加选项卡,如果使用锚点选项卡定位,则可以在开头定义它们。或者,您可以在将文档添加到信封后将选项卡添加到信封定义中。

谢谢大家的回答。 我以这种方式解决了问题: - 第2步:在每个添加的文件上设置参数apply_document_fields, - 步骤3:在将其设置为"已发送"之前,再次设置信封中的收件人。 从我的角度来看,这个问题已经解决了。

最新更新