如何将标记添加到动态添加到模板的文档中

本文关键字:添加 文档 动态 | 更新日期: 2023-09-27 18:22:25

我能够通过API成功地将文档添加到模板中,现在我想将多个签名选项卡和初始选项卡添加到刚刚通过API使用.net c#库添加的文档中。我创建了下面的选项卡,创建了信封并添加了文档。我是否必须将选项卡添加到文档或模板或其他内容?

//Create tabs to be added to do the document.
Tabs tabList = new Tabs()
{
    signHereTabs = new Tab[]
    {
        new Tab()
        {
            documentId = 5,
            pageNumber = 1,
            xPosition = 100,
            yPosition = 150
        }
    },
    initialHereTabs = new Tab[]
    {
    new Tab(){
        documentId = 5,
        pageNumber = 1,
        xPosition = 100,
        yPosition = 150
    }
    }
};
//Create template envolope and its template role
byte[] ips = GetIPS("");
RestSettings.Instance.DocuSignAddress = "https://demo.docusign.net";
RestSettings.Instance.WebServiceUrl = RestSettings.Instance.DocuSignAddress + "/restapi/v2";
RestSettings.Instance.IntegratorKey = integratorKey;
DocuSign.Integrations.Client.Account account = new DocuSign.Integrations.Client.Account();
account.Email = username;
account.Password = password;
var loginResult = account.Login();

Template template = new Template();
template.TemplateId = templateId;
template.Login = account;

template.EmailSubject = emailSubject;
template.EmailBlurb = emailMessage;
var documents = template.GetDocuments();

var roles = new List<TemplateRole>();

//Handle Primary Client
roles.Add(new TemplateRole
{
    roleName = "Primary Client",
    name = primaryClientName,
    email = primaryClientEmail,
    tabs = new RoleTabs
    {
    textTabs = new RoleTextTab[] {
        new RoleTextTab {
        tabLabel = "FeeEffectiveDate",
        value = effectiveDate
        },
        new RoleTextTab {
        tabLabel = "FeePercentage",
        value = fee
        }
    },
    },
});
if (secondaryClientName.Trim().Length != 0)
{
    roles.Add(new TemplateRole
    {
    roleName = "Secondary Client",
    name = secondaryClientName,
    email = secondaryClientEmail,
    });
}
roles.Add(new TemplateRole
{
    roleName = "President",
    name = presidentName,
    email = presidentEmail
});
roles.Add(new TemplateRole
{
    roleName = "Css",
    name = cssName,
    email = cssEmail
});
template.TemplateRoles = roles.ToArray<TemplateRole>();
template.Status = "created";
var result = template.Create();
//Add the document to the template
bool status = template.AddDocument(ips, "IPS.pdf", 5);
//-------------------------------------------------------------------------
//Now I need to add tabslist created previously to the document.  How do I do this?
//--------------------------------------------------------------------------
template.Status = "sent";
result = template.UpdateStatus();
return result;

如何将标记添加到动态添加到模板的文档中

经过几次尝试和错误之后,我能够做到这一点。标记/选项卡需要使用其AddTabs功能添加到模板中。

TabCollection ipsTabs = new TabCollection();
ipsTabs.signHereTabs = new List<Tab>();
ipsTabs.signHereTabs.Add(new Tab()
{
    documentId = 5,
    anchorString = "soc1",
    recipientId = "1",
    xPosition = 100,
    yPosition = 150
});
ipsTabs.signHereTabs.Add(new Tab()
{
    documentId = 5,
    anchorString = "soc2",
    recipientId = "2",
    xPosition = 100,
    yPosition = 150
});
ipsTabs.initialHereTabs = new List<Tab>();
ipsTabs.initialHereTabs.Add(new Tab()
{
    documentId = 5,
    anchorString = "ci1",
    recipientId = "1",
    xPosition = -100,
    yPosition = 150
});
ipsTabs.initialHereTabs.Add(new Tab()
{
    documentId = 5,
    anchorString = "ci2",
    recipientId = "2",
    xPosition = -100,
    yPosition = 150
});
var tabstatus = template.AddTabs(ipsTabs);