protected override void Execute(CodeActivityContext context) { Initialize(context); FullNameTab fullNameTab; if (anchorText != null) { fullNameTab = new FullNameTab(anchorText, offsetX, offsetY, doc.documentId, pageNumber, toolTip, tabLabel, bold, italic, underline, font, fontColor, fontSize); } else { fullNameTab = new FullNameTab(sigX, sigY, doc.documentId, pageNumber, toolTip, tabLabel, bold, italic, underline, font, fontColor, fontSize); } AddTabToRecipient(fullNameTab); }
public static void Main() { DocuSignCredentials credentials = new DocuSignCredentials(); credentials.username = ""; // your account email credentials.password = ""; // your account password credentials.integratorKey = ""; // your account Integrator Key (found on Preferences -> API page) credentials.accountId = ""; credentials.baseUrl = "https://demo.docusign.net/"; DocuSignClient client = new DocuSignClient(credentials); Envelope envelope = new Envelope(); envelope.status = "sent"; envelope.emailSubject = "Test API Call Create Envelope"; Signer signer = new Signer(); signer.email = ""; signer.name = ""; signer.recipientId = 1; SignHereTab signHereTab = new SignHereTab(); signHereTab.anchorString = "/S1Sign/"; signHereTab.anchorXOffset = "-20"; signHereTab.anchorYOffset = "120"; InitialHereTab initialHereTab = new InitialHereTab(); initialHereTab.anchorString = "/S1Initial/"; initialHereTab.anchorXOffset = "10"; initialHereTab.anchorYOffset = "120"; FullNameTab fullNameTab = new FullNameTab(); fullNameTab.anchorString = "/S1FullName/"; fullNameTab.anchorXOffset = "-20"; fullNameTab.anchorYOffset = "120"; DateSignedTab dateSignedTab = new DateSignedTab(); dateSignedTab.anchorString = "/S1Date/"; dateSignedTab.anchorXOffset = "-20"; dateSignedTab.anchorYOffset = "120"; signer.tabs = new Tabs(); signer.tabs.signHereTabs = new List <SignHereTab>(); signer.tabs.signHereTabs.Add(signHereTab); signer.tabs.initialHereTabs = new List <InitialHereTab>(); signer.tabs.initialHereTabs.Add(initialHereTab); signer.tabs.fullNameTabs = new List <FullNameTab>(); signer.tabs.fullNameTabs.Add(fullNameTab); signer.tabs.dateSignedTabs = new List <DateSignedTab>(); signer.tabs.dateSignedTabs.Add(dateSignedTab); envelope.recipients = new Recipients(); envelope.recipients.signers = new List <Signer>(); envelope.recipients.signers.Add(signer); Document document = new Document(); document.name = "Try DocuSigning.docx"; // copy document with same name and extension into project directory (i.e. "test.pdf") document.documentId = 1; envelope.documents = new List <Document>(); envelope.documents.Add(document); CreateEnvelopeResponse response = client.CreateAndSendEnvelope(envelope); Trace.WriteLine(response); }
protected void createEnvelope() { // Set up the envelope CreateEnvelopeRequest createEnvelopeRequest = new CreateEnvelopeRequest(); createEnvelopeRequest.emailSubject = "eNotary Example"; createEnvelopeRequest.status = "sent"; //Define inperson signers InPersonSigner inPersonSigner = new InPersonSigner(); // inPersonSigner.hostEmail = "*****@*****.**"; inPersonSigner.hostEmail = email.Value; inPersonSigner.hostName = firstname.Value + " " + lastname.Value; inPersonSigner.recipientId = "3"; inPersonSigner.routingOrder = "3"; inPersonSigner.inPersonSigningType = "notary"; NotaryHost notaryHost = new NotaryHost(); notaryHost.recipientId = 4; notaryHost.email = notaryEmail.Value; notaryHost.name = notaryFirstname.Value + " " + notaryLastname.Value; // Add tab for the recipient inPersonSigner.tabs = new Tabs(); inPersonSigner.tabs.signHereTabs = new List <SignHereTab>(); SignHereTab signHereTab = new SignHereTab(); signHereTab.documentId = "1"; signHereTab.pageNumber = "1"; signHereTab.tabId = "1"; signHereTab.xPosition = "110"; signHereTab.yPosition = "210"; signHereTab.name = "sigTab"; inPersonSigner.tabs.signHereTabs.Add(signHereTab); inPersonSigner.tabs.dateSignedTabs = new List <DateSignedTab>(); DateSignedTab dateSignedTab = new DateSignedTab(); dateSignedTab.documentId = "1"; dateSignedTab.pageNumber = "1"; dateSignedTab.tabId = "2"; dateSignedTab.xPosition = "425"; dateSignedTab.yPosition = "260"; dateSignedTab.name = "dateSignedTab"; inPersonSigner.tabs.dateSignedTabs.Add(dateSignedTab); inPersonSigner.tabs.fullNameTabs = new List <FullNameTab>(); FullNameTab fullNameTab = new FullNameTab(); fullNameTab.documentId = "1"; fullNameTab.pageNumber = "1"; fullNameTab.tabId = "3"; fullNameTab.xPosition = "90"; fullNameTab.yPosition = "150"; fullNameTab.name = "fullNameTab"; inPersonSigner.tabs.fullNameTabs.Add(fullNameTab); inPersonSigner.notaryHost = notaryHost; // Define a document Document document = new Document(); document.documentId = "1"; document.name = "Sample Form"; document.transformPdfFields = "true"; //document.display = "modal"; // Define an inline template InlineTemplate inline1 = new InlineTemplate(); inline1.sequence = "2"; inline1.recipients = new Recipients(); // inline1.recipients.signers = new List<Signer>(); // inline1.recipients.signers.Add(signer); inline1.recipients.inPersonSigners = new List <InPersonSigner>(); inline1.recipients.inPersonSigners.Add(inPersonSigner); // inline1.documents = new List<Document>(); // inline1.documents.Add(document); ServerTemplate serverTemplate1 = new ServerTemplate(); serverTemplate1.sequence = "1"; serverTemplate1.templateId = "d7a2c6d9-3b20-4086-a408-ada85efc00fd"; CompositeTemplate compositeTemplate1 = new CompositeTemplate(); compositeTemplate1.inlineTemplates = new List <InlineTemplate>(); compositeTemplate1.inlineTemplates.Add(inline1); // compositeTemplate1.serverTemplates = new List<ServerTemplate>(); // compositeTemplate1.serverTemplates.Add(serverTemplate1); compositeTemplate1.document = document; compositeTemplate1.document = new Document(); compositeTemplate1.document.documentId = "1"; compositeTemplate1.document.name = "Affidavit"; compositeTemplate1.document.transformPdfFields = "true"; //compositeTemplate1.document.display = "modal"; createEnvelopeRequest.compositeTemplates = new List <CompositeTemplate>(); createEnvelopeRequest.compositeTemplates.Add(compositeTemplate1); string output = JsonConvert.SerializeObject(createEnvelopeRequest); accountId.Value = ConfigurationManager.AppSettings["API.NotaryAccountID"]; // Specify a unique boundary string that doesn't appear in the json or document bytes. string Boundary = "MY_BOUNDARY"; // Set the URI HttpWebRequest request = HttpWebRequest.Create(ConfigurationManager.AppSettings["DocuSignServer"] + "/restapi/v2/accounts/" + accountId.Value + "/envelopes") as HttpWebRequest; // Set the method request.Method = "POST"; // Set the authentication header request.Headers["X-DocuSign-Authentication"] = GetSecurityHeader(); // Set the overall request content type aand boundary string request.ContentType = "multipart/form-data; boundary=" + Boundary; request.Accept = "application/json"; // Start forming the body of the request Stream reqStream = request.GetRequestStream(); // write boundary marker between parts WriteStream(reqStream, "\n--" + Boundary + "\n"); // write out the json envelope definition part WriteStream(reqStream, "Content-Type: application/json\n"); WriteStream(reqStream, "Content-Disposition: form-data\n"); WriteStream(reqStream, "\n"); // requires an empty line between the header and the json body WriteStream(reqStream, output); // write out the form bytes for the first form WriteStream(reqStream, "\n--" + Boundary + "\n"); WriteStream(reqStream, "Content-Type: application/pdf\n"); WriteStream(reqStream, "Content-Disposition: file; filename=\"Sample_Form\"; documentId=1\n"); WriteStream(reqStream, "\n"); String filename = "Docusign_Affidavit.pdf"; if (File.Exists(Server.MapPath("~/App_Data/" + filename))) { // Read the file contents and write them to the request stream byte[] buf = new byte[4096]; int len; // read contents of document into the request stream FileStream fileStream = File.OpenRead(Server.MapPath("~/App_Data/" + filename)); while ((len = fileStream.Read(buf, 0, 4096)) > 0) { reqStream.Write(buf, 0, len); } fileStream.Close(); } // wrte the end boundary marker - ensure that it is on its own line WriteStream(reqStream, "\n--" + Boundary + "--"); WriteStream(reqStream, "\n"); try { HttpWebResponse response = request.GetResponse() as HttpWebResponse; if (response.StatusCode == HttpStatusCode.Created) { byte[] responseBytes = new byte[response.ContentLength]; using (var reader = new System.IO.BinaryReader(response.GetResponseStream())) { reader.Read(responseBytes, 0, responseBytes.Length); } string responseText = Encoding.UTF8.GetString(responseBytes); CreateEnvelopeResponse createEnvelopeResponse = new CreateEnvelopeResponse(); createEnvelopeResponse = JsonConvert.DeserializeObject <CreateEnvelopeResponse>(responseText); if (createEnvelopeResponse.status.Equals("sent")) { Response.Redirect("ConfirmationPage.aspx"); } } } catch (WebException ex) { if (ex.Status == WebExceptionStatus.ProtocolError) { HttpWebResponse response = (HttpWebResponse)ex.Response; using (var reader = new System.IO.StreamReader(ex.Response.GetResponseStream(), UTF8Encoding.UTF8)) { string errorMess = reader.ReadToEnd(); log4net.ILog logger = log4net.LogManager.GetLogger(typeof(demos_eNotary)); logger.Info("\n----------------------------------------\n"); logger.Error("DocuSign Error: " + errorMess); logger.Error(ex.StackTrace); Response.Write(ex.Message); } } else { log4net.ILog logger = log4net.LogManager.GetLogger(typeof(demos_eNotary)); logger.Info("\n----------------------------------------\n"); logger.Error("WebRequest Error: " + ex.Message); logger.Error(ex.StackTrace); Response.Write(ex.Message); } } }