DocuSign Java Rest Api - 结合锚标记自定义文件和 PDF 表单字段转换(复合模板)

2023-12-11

在我的应用程序中,我有一个 PDF 包,我将其合并并发送给 DocuSign。使用 SignHere 和 Initial here AnchorTags 可以完美地完成此操作;但是,我现在需要包含某些需要用户输入字段的 PDF(例如 W-9 表单)。我尝试了多种创建模板的方法,但没有成功。我已经能够让 DocuSign 识别所有 PDF 表单字段(在模板 UI 中),但我无法将这些字段提供给用户。

我有两个重要问题:

首先,我无法让 DocuSign 同时包含我的自定义文件和我使用收件人文档中的输入字段创建的模板。

我能够将 W-9 模板发送给收件人(但不是自定义文件),但没有任何输入字段或标签。

我已将我的代码粘贴在下面

// create a new envelope to manage the signature request
EnvelopeDefinition envDef = new EnvelopeDefinition();       

envDef.setEmailSubject(documentName);

// add a document to the envelope
Document doc = new Document();          
doc.setDocumentBase64(Base64.getEncoder().encodeToString(fileBytes)); //custom file
doc.setName(documentName); 

//this is the objectid of the ElectronicDocument
doc.setDocumentId(ElectronicDocumentId); 

List<Document> docs = new ArrayList<Document>();
docs.add(doc);
envDef.setDocuments(docs); 


Signer signer = new Signer(); 
signer.setEmail(primarySignerEmail);
signer.setName(primarySignerName);
signer.setRecipientId(primarySignerId); 
signer.setAccessCode(primaryAuthCode); 
signer.setRoleName("PrimaryTenant"); //so we attach them to w9template


////create tab code not included

//create the tabs and assign to signer
Tabs tabs = new Tabs();
tabs.setSignHereTabs(signHereTabs); 
tabs.setInitialHereTabs(initialHereTabs);
tabs.setDateSignedTabs(dateSignedTabs);
signer.setTabs(tabs);


Blob     blob = w9Template.getFileBlob();
int blobLength;
try {
    blobLength = (int) blob.length();
    w9Bytes = blob.getBytes(1, blobLength);     
    blob.free();
} catch (SQLException e) {
    logger.warn(e);
}  

if (w9Bytes != null){

    //create compositTemplate for w-9
    CompositeTemplate compositeTemplate = new CompositeTemplate();
    InlineTemplate inlineTemplate = new InlineTemplate();
    inlineTemplate.setSequence("2");


    //create w-9 document
    Document docw9 = new Document();    
    docw9.setDocumentBase64(Base64.getEncoder().encodeToString(w9Bytes));
    docw9.setName("W-9");               
    docw9.setDocumentId(ElectronicDocumentId); 
    docw9.transformPdfFields("true");

    compositeTemplate.document(docw9);

    inlineTemplate.setRecipients(new Recipients());
    inlineTemplate.getRecipients().setSigners(new ArrayList<Signer>());
    inlineTemplate.getRecipients().getSigners().add(signer);

    List<InlineTemplate> inlineTemplateList = new ArrayList<InlineTemplate>();
    inlineTemplateList.add(inlineTemplate);
    compositeTemplate.inlineTemplates(inlineTemplateList);

    List<CompositeTemplate> compositeTemplateList = new ArrayList<CompositeTemplate>();
    compositeTemplateList.add(compositeTemplate);
    envDef.setCompositeTemplates(compositeTemplateList);            

}

// add recipient(s) to the envelope
envDef.setRecipients(new Recipients());
envDef.getRecipients().setSigners(new ArrayList<Signer>());
envDef.getRecipients().getSigners().add(signer);


// send the envelope by setting |status| to "sent". To save as a draft set to "created"
envDef.setStatus("sent");

try
{               
    // instantiate a new EnvelopesApi object
    EnvelopesApi envelopesApi = new EnvelopesApi();

   // call the createEnvelope() API
   // use the |accountId| we retrieved through authenticate() function to      create the Envelope
  EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envDef);
        logger.debug("EnvelopeSummary: " + envelopeSummary);
}
catch (com.docusign.esign.client.ApiException ex)
{

} 

在此先感谢您的努力。我一整天都在试图解决这个问题。


当您在信封定义中指定复合模板时,只有在 CompositeTemplate 中指定的信息才会用于创建信封。

对于您的场景,您可以使用两个 CompositeTemplate 并在两个模板中指定相同的签名者。为了识别 PDF 表单字段,您必须将签名者的“DefaultRecipient”属性设置为 true。

您可以在自己的 CompositeTemplate 中指定每个文档。这将确保您的两份文件都包含在信封中。

我已经更新了你的代码

// create a new envelope to manage the signature request
EnvelopeDefinition envDef = new EnvelopeDefinition();       
envDef.setEmailSubject(documentName);

// add a document to the envelope
Document doc = new Document();          
doc.setDocumentBase64(Base64.getEncoder().encodeToString(fileBytes)); //custom file
doc.setName(documentName); 

//this is the objectid of the ElectronicDocument
doc.setDocumentId(ElectronicDocumentId); 

Signer signer = new Signer(); 
signer.setEmail(primarySignerEmail);
signer.setName(primarySignerName);
signer.setRecipientId(primarySignerId); 
signer.setAccessCode(primaryAuthCode); 
signer.setDefaultRecipient("true");
signer.setRoleName("PrimaryTenant"); //so we attach them to w9template


////create tab code not included

//create the tabs and assign to signer
Tabs tabs = new Tabs();
tabs.setSignHereTabs(signHereTabs); 
tabs.setInitialHereTabs(initialHereTabs);
tabs.setDateSignedTabs(dateSignedTabs);
signer.setTabs(tabs);

CompositeTemplate compositeTemplate1 = new CompositeTemplate();
InlineTemplate inlineTemplate1 = new InlineTemplate();
inlineTemplate1.setSequence("1");

compositeTemplate1.document(doc);

inlineTemplate1.setRecipients(new Recipients());
inlineTemplate1.getRecipients().setSigners(new ArrayList<Signer>());
inlineTemplate1.getRecipients().getSigners().add(signer);

List<InlineTemplate> inlineTemplateList1 = new ArrayList<InlineTemplate>();
inlineTemplateList1.add(inlineTemplate1);
compositeTemplate.inlineTemplates(inlineTemplateList1);

 List<CompositeTemplate> compositeTemplateList = new ArrayList<CompositeTemplate>();
 compositeTemplateList.add(compositeTemplate1);


 Blob     blob = w9Template.getFileBlob();
 int blobLength;
 try 
 {
    blobLength = (int) blob.length();
    w9Bytes = blob.getBytes(1, blobLength);     
    blob.free();
 } catch (SQLException e) {
    logger.warn(e);
 }  

if (w9Bytes != null)
{
    //create compositTemplate for w-9
    CompositeTemplate compositeTemplate2 = new CompositeTemplate();
    InlineTemplate inlineTemplate2 = new InlineTemplate();
    inlineTemplate2.setSequence("2");


    //create w-9 document
    Document docw9 = new Document();    
    docw9.setDocumentBase64(Base64.getEncoder().encodeToString(w9Bytes));
    docw9.setName("W-9");               
    docw9.setDocumentId(ElectronicDocumentId); 
    docw9.transformPdfFields("true");

    compositeTemplate2.document(docw9);

    Signer signer2 = new Signer(); 
    signer2.setEmail(primarySignerEmail);
    signer2.setName(primarySignerName);
    signer2.setRecipientId(primarySignerId); 
    signer2.setAccessCode(primaryAuthCode);
    signer2.setDefaultRecipient("true");

    inlineTemplate2.setRecipients(new Recipients());
    inlineTemplate2.getRecipients().setSigners(new ArrayList<Signer>());
    inlineTemplate2.getRecipients().getSigners().add(signer2);

    List<InlineTemplate> inlineTemplateList2 = new ArrayList<InlineTemplate>();
    inlineTemplateList2.add(inlineTemplate);
    compositeTemplate2.inlineTemplates(inlineTemplateList2);

    compositeTemplateList.add(compositeTemplate2); 
}

envDef.setCompositeTemplates(compositeTemplateList); 



// send the envelope by setting |status| to "sent". To save as a draft set to "created"
envDef.setStatus("sent");

try
{               
    // instantiate a new EnvelopesApi object
    EnvelopesApi envelopesApi = new EnvelopesApi();

   // call the createEnvelope() API
   // use the |accountId| we retrieved through authenticate() function to      create the Envelope
    EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envDef);
        logger.debug("EnvelopeSummary: " + envelopeSummary);
}
catch (com.docusign.esign.client.ApiException ex)
{

} 
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

DocuSign Java Rest Api - 结合锚标记自定义文件和 PDF 表单字段转换(复合模板) 的相关文章

  • 在 C# 中通过 DocuSign api 登录时出现“操作已超时”错误

    自 2018 年 5 月 31 日起 我在登录 DocuSign API 时收到以下错误 DocuSign eSign Client ApiException 调用登录时出错 操作已超时 自去年以来 我们一直在测试 DocuSign API
  • Docusign 签名 url - 显示复合模板的文档 1

    使用 docusign rest api 我想创建一个包含 2 个文档的信封 然后我将使用收件人帖子视图向第一个收件人 在 iframe 中 显示文档 1 签名后将同一信封中的文档 2 显示给其他收件人 我创建了具有不同 tempalteR
  • DocuSign:Rest API C# 为签名者获取永久链接

    我正在使用 DocuSign 的 REST API 以嵌入式签名模式创建信封 使用 CreateRecipientView 函数我只得到一个临时链接 但我更希望获得像通知邮件中那样的永久链接 我怎样才能得到这个链接 URL 使用 DocuS
  • Docusign 代表发送 (SOBO)

    如果有人有 我欢迎提供有关如何使用 Docusign 的代表发送 SOBO 功能的示例 我正在使用带有 XML 的 SOAP API 甚至 Docusign 的 III 级支持也无法提供示例 Thanks 2021 年 4 月更新 新的 R
  • 调用 EnvelopesApi#update_document_tabs 返回错误

    我想一次更新文档的所有选项卡 该文档的信封是根据已定义收件人和选项卡的模板创建的 我正在调用this具有以下有效负载的端点来更新选项卡 textTabs validationPattern validationMessage shared
  • DocuSign REST api 取消分组选项卡

    我需要取消在 草稿 状态下创建的信封中的选项卡的分组 这样 如果我在一页上移动一个 SignHere 选项卡位置 所有其他 SignHere 都不会移动 我执行了 GET 请求来获取选项卡 然后执行 PUT 请求来更新选项卡 通信成功 但选
  • DocuSign Connect X.509 证书身份验证/安全

    如何保护我的 DocuSign Connect https 侦听器 以便仅接受来自 DocuSign 的请求 我已阅读 Connect 服务指南 但不清楚以下设置是否可用于此目的 使用 X509 证书签署消息 此设置是否同时适用于 SOAP
  • DocuSign 认证的严格性

    来自 DocuSign API 要求信息 Y 我们的 API 认证审核涉及验证您是否每 15 分钟每个唯一信封的状态请求不超过 1 个 以便对以下方法进行轮询合规性 REST API GET accounts accountId envel
  • DocuSign getRecipientView ttl_expired 错误

    我正在使用 DocuSign API 发布到收件人帖子视图 URL 我收到一个响应 URL 但如果我按照该 URL 操作 它会告诉我 event ttl expired 示例网址 https demo docusign net Signin
  • 如何通过浏览器javascript访问Docusign API?

    我正在用 Javascript 构建一个基于浏览器的应用程序 我尝试通过 jQuery 访问 docusign api support cors true ajax crossDomain true url https demo docus
  • listStatus 端点包括响应中的收件人状态

    有没有办法在 listStatus 端点的响应正文中包含收件人状态 这是我提出的卷曲请求 curl X PUT https na2 docusign net restapi v2 accounts XXXXX envelopes statu
  • JWT OAuth 身份验证流程中的“错误请求”消息

    我已按照文档中的所有说明生成 JWT 令牌 但只收到 错误请求 作为响应 当我尝试运行 eg 01 php jwt 时 会发生同样的情况 我正在使用 DocuSign 演示环境并使用 Postman 和curl 模拟请求 我正在做的步骤是
  • Docusign XML 检查为复选框

    我正在尝试填充模板上的复选框 文档位于https www docusign com p APIGuide Content Sending 20Group Tab htm https www docusign com p APIGuide C
  • docusign 代表发送功能

    总的来说 我是 docusign 和 api 的新手 我已在 docusign 上手动创建了一个主帐户 现在我想使用此帐户创建新用户并使用代表发送功能 我已经浏览过这个 pdf http www docusign com sites def
  • DocuSign API:在同一信封中发送多个文档的签名问题

    使用 C DocuSign API SDK 4 5 2 我将在同一个信封中寄出 3 份文件以供签名 每个文档将使用相同的服务器模板 它只是使用锚标记将签名元素放置在文档上 我可以寄出信封 然后从 DocuSign 收到电子邮件以查看 签署文
  • 检查文档状态 DocuSign

    如何检查文档是否已使用 DocuSign API 签名 是否存在可以让我了解文档状态的 API 服务 我尝试获取 已完成 文件夹中的所有对象 但响应不包含 documentId 并且我不知道每个对象是哪个文档 DocuSign 轨道接受者状
  • 为什么我的 WCF Web 服务在具有不同字段名称的不同命名空间中呈现此对象?

    上下文 我正在尝试与 DocuSign 的 Connect 通知服务集成 我已经使用名为 DocuSignConnectUpdate 的方法设置了 WCF 服务 该方法将 DocuSignEnvelopeInformation 作为其唯一参
  • 作为依赖项和不同的 publicKeyToken 共享时 RestSharp 错误

    使用来自的 APIDocusign Twilio and Auth0 全部 3 个都有RestSharp dll作为依赖 如果我使用RestSharp dll包含在Docusign包裹 Docusign效果很好但是Auth0 and Twi
  • 如何使用 Docusign 的 REST API 预填充从模板创建的信封中的字段?

    注意 我使用的是 经典 体验 因为新界面无法让模板为未来的签名者设置必填字段 工作流程 有一个包含一堆字段的模板 使用 API 从模板创建一个信封 文档 并指定一个新用户进行签名 该文档将成为注册服务的协议 创建新角色 在模板上将 role
  • Docusign - 更改已完成签名通知电子邮件消息/简介

    我想这很简单 只是我没有找到正确的位置 有没有一种方法可以为已完成的签名电子邮件通知编写自定义电子邮件简介 就像您可以在嵌入式签名 API 代码中为签名通知请求生成自定义电子邮件简介一样 目前 我的集成已嵌入第一个签名者 然后通过电子邮件发

随机推荐