在现有的PDF文件中设置签名占位符。

huangapple go评论83阅读模式
英文:

Set signature placeholder in existing pdf file

问题

我有一个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 = "请签署此文件";
    Document doc1 = new Document();

    string doc1b64 = Convert.ToBase64String(buffer);

    doc1.DocumentBase64 = doc1b64;
    doc1.Name = "Lorem Ipsum"; // 可以与实际文件名不同
    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;
}

在现有的PDF文件中设置签名占位符。

英文:

在现有的PDF文件中设置签名占位符。

I have pdf file. Is there any way to set signature placeholder using docusign in that pdf file?

I am not sure what's wrong here. so I am adding fully code here. It is not allowing me to save so adding some more text.

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 = &quot;Please sign this document&quot;;
    Document doc1 = new Document();

    string doc1b64 = Convert.ToBase64String(buffer);

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

    envelopeDefinition.Documents = new List&lt;Document&gt; { doc1 };

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

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

    Tabs signer1Tabs = new Tabs
    {
        SignHereTabs = new List&lt;SignHere&gt; { signHere1 },
    };
    signer1.Tabs = signer1Tabs;

    Recipients recipients = new Recipients
    {
        Signers = new List&lt;Signer&gt; { signer1 },
    };
    envelopeDefinition.Recipients = recipients;

    envelopeDefinition.Status = &quot;sent&quot;;

    return envelopeDefinition;
}

答案1

得分: 1

是的,当然可以。
以下是一篇文章,展示了如何执行此操作,以及相关的C#代码:

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

EnvelopeDefinition env = new EnvelopeDefinition();
env.EmailSubject = "请签署此文件集";

// 创建文档对象,每个文档一个
Document doc1 = new Document();
string b64 = Convert.ToBase64String(Document1(signerEmail, signerName, ccEmail, ccName));
doc1.DocumentBase64 = b64;
doc1.Name = "订单确认"; // 可以与实际文件名不同
doc1.FileExtension = "html"; // 源数据格式,签署后的文档始终为pdf
doc1.DocumentId = "1"; // 用于引用文档的标签
Document doc2 = new Document
{
    DocumentBase64 = doc2DocxBytes,
    Name = "作战计划", // 可以与实际文件名不同
    FileExtension = "docx",
    DocumentId = "2",
};
Document doc3 = new Document
{
    DocumentBase64 = doc3PdfBytes,
    Name = "Lorem Ipsum", // 可以与实际文件名不同
    FileExtension = "pdf",
    DocumentId = "3",
};

// 文档数组中的顺序决定了信封中的顺序
env.Documents = new List<Document> { doc1, doc2, doc3 };

// 创建签署人接收者以签署文件,通过名称和电子邮件地址标识
// 我们通过对象创建来设置参数
Signer signer1 = new Signer
{
    Email = signerEmail,
    Name = signerName,
    RecipientId = "1",
    RoutingOrder = "1",
};

// routingOrder(数字越低,表示越早交付)
// 决定了发送给接收者的交付顺序。通过使用相同的整数作为两个或更多接收者的顺序,支持并行路由顺序。

// 创建抄送接收者以接收文档的副本,通过名称和电子邮件地址标识
// 通过设置器来设置参数
CarbonCopy cc1 = new CarbonCopy
{
    Email = ccEmail,
    Name = ccName,
    RecipientId = "2",
    RoutingOrder = "2",
};

// 在文档上创建signHere字段(也称为标签),
// 我们使用锚点(autoPlace)定位
//
// DocuSign平台会在信封的文档中搜索匹配的锚点字符串。因此,
// signHere2标签将在文档2和3中都使用,因为它们
// 使用相同的锚点字符串用于其“签署人1”标签。
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 signer1Tabs = new Tabs
{
    SignHereTabs = new List<SignHere> { signHere1, signHere2 },
};
signer1.Tabs = signer1Tabs;

// 将接收者添加到信封对象
Recipients recipients = new Recipients
{
    Signers = new List<Signer> { signer1 },
    CarbonCopies = new List<CarbonCopy> { cc1 },
};
env.Recipients = recipients;

// 通过将|status|设置为“sent”来请求发送信封。
// 若要请求创建信封作为草稿,请将其设置为“created”
env.Status = envStatus;

return env;
英文:

Yes, sure, of course.
Here is an article showing how to do that and here is the relevant C# code:

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

EnvelopeDefinition env = new EnvelopeDefinition();
env.EmailSubject = &quot;Please sign this document set&quot;;
// Create document objects, one per document
Document doc1 = new Document();
string b64 = Convert.ToBase64String(Document1(signerEmail, signerName, ccEmail, ccName));
doc1.DocumentBase64 = b64;
doc1.Name = &quot;Order acknowledgement&quot;; // can be different from actual file name
doc1.FileExtension = &quot;html&quot;; // Source data format. Signed docs are always pdf.
doc1.DocumentId = &quot;1&quot;; // a label used to reference the doc
Document doc2 = new Document
{
DocumentBase64 = doc2DocxBytes,
Name = &quot;Battle Plan&quot;, // can be different from actual file name
FileExtension = &quot;docx&quot;,
DocumentId = &quot;2&quot;,
};
Document doc3 = new Document
{
DocumentBase64 = doc3PdfBytes,
Name = &quot;Lorem Ipsum&quot;, // can be different from actual file name
FileExtension = &quot;pdf&quot;,
DocumentId = &quot;3&quot;,
};
// The order in the docs array determines the order in the envelope
env.Documents = new List&lt;Document&gt; { doc1, doc2, doc3 };
// create a signer recipient to sign the document, identified by name and email
// We&#39;re setting the parameters via the object creation
Signer signer1 = new Signer
{
Email = signerEmail,
Name = signerName,
RecipientId = &quot;1&quot;,
RoutingOrder = &quot;1&quot;,
};
// 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&#39;re setting the parameters via setters
CarbonCopy cc1 = new CarbonCopy
{
Email = ccEmail,
Name = ccName,
RecipientId = &quot;2&quot;,
RoutingOrder = &quot;2&quot;,
};
// Create signHere fields (also known as tabs) on the documents,
// We&#39;re using anchor (autoPlace) positioning
//
// The DocuSign platform searches throughout your envelope&#39;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 &quot;signer 1&quot; tabs.
SignHere signHere1 = new SignHere
{
AnchorString = &quot;**signature_1**&quot;,
AnchorUnits = &quot;pixels&quot;,
AnchorYOffset = &quot;10&quot;,
AnchorXOffset = &quot;20&quot;,
};
SignHere signHere2 = new SignHere
{
AnchorString = &quot;/sn1/&quot;,
AnchorUnits = &quot;pixels&quot;,
AnchorYOffset = &quot;10&quot;,
AnchorXOffset = &quot;20&quot;,
};
// Tabs are set per recipient / signer
Tabs signer1Tabs = new Tabs
{
SignHereTabs = new List&lt;SignHere&gt; { signHere1, signHere2 },
};
signer1.Tabs = signer1Tabs;
// Add the recipients to the envelope object
Recipients recipients = new Recipients
{
Signers = new List&lt;Signer&gt; { signer1 },
CarbonCopies = new List&lt;CarbonCopy&gt; { cc1 },
};
env.Recipients = recipients;
// Request that the envelope be sent by setting |status| to &quot;sent&quot;.
// To request that the envelope be created as a draft, set to &quot;created&quot;
env.Status = envStatus;
return env;

huangapple
  • 本文由 发表于 2023年7月12日 21:33:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/76671162.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定