Skip to content

Instantly share code, notes, and snippets.

@Ergin008
Last active July 9, 2016 02:17
Show Gist options
  • Save Ergin008/cc771595ed2697082861 to your computer and use it in GitHub Desktop.
Save Ergin008/cc771595ed2697082861 to your computer and use it in GitHub Desktop.
code snippet that shows how to create an envelope using the DocuSign .NET client
// specify the document we want signed
string SignTest1File = @"[PATH/TO/DOCUMENT/TEST.PDF]";
// read a file from disk to use as a document.
byte[] fileBytes = File.ReadAllBytes(SignTest1File);
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";
// Add a document to the envelope
Document doc = new Document();
doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
doc.Name = "TestFile.pdf";
doc.DocumentId = "1";
envDef.Documents = new List<Document>();
envDef.Documents.Add(doc);
// Add a recipient to sign the documeent
Signer signer = new Signer();
signer.Email = "[SIGNER_EMAIL]";
signer.Name = "[SIGNER_NAME]";
signer.RecipientId = "1";
// must set |clientUserId| to embed the recipient
signer.ClientUserId = "1234";
// Create a |SignHere| tab somewhere on the document for the recipient to sign
signer.Tabs = new Tabs();
signer.Tabs.SignHereTabs = new List<SignHere>();
SignHere signHere = new SignHere();
signHere.DocumentId = "1";
signHere.PageNumber = "1";
signHere.RecipientId = "1";
signHere.XPosition = "100";
signHere.YPosition = "150";
signer.Tabs.SignHereTabs.Add(signHere);
envDef.Recipients = new Recipients();
envDef.Recipients.Signers = new List<Signer>();
envDef.Recipients.Signers.Add(signer);
// set envelope status to "sent" to immediately send the signature request
envDef.Status = "sent";
// use the EnvelopesApi to crate and send the signature request
EnvelopesApi envelopesApi = new EnvelopesApi();
EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);
Console.WriteLine("EnvelopeSummary:\n{0}", JsonConvert.SerializeObject(envelopeSummary));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment