enter image description here

我有pdf文件.有没有办法在pdf文件中使用DocuSign设置签名占位符?

我不确定这里出了什么问题.所以我在这里添加了完整的代码.它不允许我保存,所以添加了一些更多的文本.

public static EnvelopeDefinition MakeEnvelope(string signerEmail, string signerName, string signerClientId, string docPdf)
{
    byte[] buffer = System.IO.File.ReadAllBytes(docPdf);

    EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition();
    envelopeDefinition.EmailSubject = "Please sign this document";
    Document doc1 = new Document();

    string doc1b64 = Convert.ToBase64String(buffer);

    doc1.DocumentBase64 = doc1b64;
    doc1.Name = "Lorem Ipsum"; // can be different from actual file name
    doc1.FileExtension = "pdf";
    doc1.DocumentId = "3";

    envelopeDefinition.Documents = new List<Document> { doc1 };

    Signer signer1 = new Signer
    {
        Email = signerEmail,
        Name = signerName,
        ClientUserId = signerClientId,
        RecipientId = "1",
    };

    SignHere signHere1 = new SignHere
    {
        AnchorString = "/sn1/",
        AnchorUnits = "pixels",
        AnchorXOffset = "10",
        AnchorYOffset = "20",
    };

    Tabs signer1Tabs = new Tabs
    {
        SignHereTabs = new List<SignHere> { signHere1 },
    };
    signer1.Tabs = signer1Tabs;

    Recipients recipients = new Recipients
    {
        Signers = new List<Signer> { signer1 },
    };
    envelopeDefinition.Recipients = recipients;

    envelopeDefinition.Status = "sent";

    return envelopeDefinition;
}

推荐答案

是的,当然,当然. 下面是一篇展示如何做到这一点的文章,下面是相关的C#代码:

https://developers.docusign.com/docs/esign-rest-api/how-to/request-signature-email-remote/

EnvelopeDefinition env = new EnvelopeDefinition();
env.EmailSubject = "Please sign this document set";

// Create document objects, one per document
Document doc1 = new Document();
string b64 = Convert.ToBase64String(Document1(signerEmail, signerName, ccEmail, ccName));
doc1.DocumentBase64 = b64;
doc1.Name = "Order acknowledgement"; // can be different from actual file name
doc1.FileExtension = "html"; // Source data format. Signed docs are always pdf.
doc1.DocumentId = "1"; // a label used to reference the doc
Document doc2 = new Document
{
    DocumentBase64 = doc2DocxBytes,
    Name = "Battle Plan", // can be different from actual file name
    FileExtension = "docx",
    DocumentId = "2",
};
Document doc3 = new Document
{
    DocumentBase64 = doc3PdfBytes,
    Name = "Lorem Ipsum", // can be different from actual file name
    FileExtension = "pdf",
    DocumentId = "3",
};

// The order in the docs array determines the order in the envelope
env.Documents = new List<Document> { doc1, doc2, doc3 };

// create a signer recipient to sign the document, identified by name and email
// We're setting the parameters via the object creation
Signer signer1 = new Signer
{
    Email = signerEmail,
    Name = signerName,
    RecipientId = "1",
    RoutingOrder = "1",
};

// routingOrder (lower means earlier) determines the order of deliveries
// to the recipients. Parallel routing order is supported by using the
// same integer as the order for two or more recipients.

// create a cc recipient to receive a copy of the documents, identified by name and email
// We're setting the parameters via setters
CarbonCopy cc1 = new CarbonCopy
{
    Email = ccEmail,
    Name = ccName,
    RecipientId = "2",
    RoutingOrder = "2",
};

// Create signHere fields (also known as tabs) on the documents,
// We're using anchor (autoPlace) positioning
//
// The DocuSign platform searches throughout your envelope's
// documents for matching anchor strings. So the
// signHere2 tab will be used in both document 2 and 3 since they
// use the same anchor string for their "signer 1" tabs.
SignHere signHere1 = new SignHere
{
    AnchorString = "**signature_1**",
    AnchorUnits = "pixels",
    AnchorYOffset = "10",
    AnchorXOffset = "20",
};

SignHere signHere2 = new SignHere
{
    AnchorString = "/sn1/",
    AnchorUnits = "pixels",
    AnchorYOffset = "10",
    AnchorXOffset = "20",
};

// Tabs are set per recipient / signer
Tabs signer1Tabs = new Tabs
{
    SignHereTabs = new List<SignHere> { signHere1, signHere2 },
};
signer1.Tabs = signer1Tabs;

// Add the recipients to the envelope object
Recipients recipients = new Recipients
{
    Signers = new List<Signer> { signer1 },
    CarbonCopies = new List<CarbonCopy> { cc1 },
};
env.Recipients = recipients;

// Request that the envelope be sent by setting |status| to "sent".
// To request that the envelope be created as a draft, set to "created"
env.Status = envStatus;

return env;

Csharp相关问答推荐

`Task`只有在C#中等待时才会运行吗?

在FilePath中搜索一个词,并根据First Match从左到右提取文件路径

Blazor Foreach仅渲染最后一种 colored颜色

从应用程序图API调用访问所有者字段

自动映射程序在GroupBy之后使用项目

当前代码Cosmos DB 3.37.1:PartitionKey key key mismatch exception

System.Text.Json .NET 8多形态语法化

正在寻找新的.NET8 Blazor Web应用程序.如何将.js添加到.razor页面?

在C#.NET项目中启动时,如何等待提升的PowerShell进程退出?

WinUI 3中DoubleCollection崩溃应用程序类型的依赖属性

如何实现有条件的自定义Json转换器隐藏属性

是否可以在Entity Framework Core中使用只读 struct 作为拥有实体?

类/值和日期的泛型方法

用于ASP.NET核心的最小扩展坞

WPF如何获取有关从一个视图模型更改另一个视图模型的信息

根据优先级整理合同列表

try 访问字典中的模拟对象时引发KeyNotFoundException

避免在特定区域中设置Visual Studio代码的自动格式

单位中快照的倾斜方向

如何对列表<;列表>;使用集合表达式?