英文:
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;
}
英文:
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 = "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;
}
答案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 = "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;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论