【问题标题】:Add documents to draft envelope without signHereTabs在没有 signHereTabs 的情况下将文档添加到草稿信封
【发布时间】: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


【解决方案1】:

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

【讨论】:

  • 感谢您的回答。更多细节:在信封里我们有不止一份文件;每个文档的大小小于 25MB;所有文档的大小总和超过 25MB。
【解决方案2】:

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

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

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

附加

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

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

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

【讨论】:

    【解决方案3】:

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

    【讨论】:

      猜你喜欢
      • 2013-10-13
      • 1970-01-01
      • 2010-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多