Products Technologies Demo Docs Blog Support Company

Electronic Signatures: Requesting Signatures from Multiple Signers using Custom Signature Workflows

This sample shows how to request signatures from multiple signers by using custom signature workflows and routing signature requests to custom endpoints.

Electronic Signatures: Requesting Signatures from Multiple Signers using Custom Signature Workflows

In the default signing process, users sign a document and click the Submit button to submit signature data such as the signature image and form field data. The server-side DocumentViewer controller is processing the signature and creates a document with the patched electronic signature images.

But the DocumentViewer can be also utilized to implement custom workflows. In this sample, the DocumentViewer is essentially used to acquire the signature images from multiple signers. At the end, when all signatures are captured, the document is finalized by merging signature images into the signature fields and by signing them using a certificate.

Server-Side Processing

The acquired signature data can be forwarded to a custom HTTP endpoint given through the RedirectUrlAfterSignature property.

@Html.TXTextControl().DocumentViewer(settings =>
{
    settings.DocumentPath = "App_Data/documentflows/"
        + Model.EnvelopeId + "/template.tx";
    settings.Dock = DocumentViewerSettings.DockStyle.Fill;
    settings.SignatureSettings = new SignatureSettings() {
        OwnerName = Model.Owner,
        ShowSignatureBar = true,
        SignerInitials = Model.Signer.Initials,
        SignerName = Model.Signer.Name,
        UniqueId = Model.EnvelopeId,
        RedirectUrlAfterSignature = Url.Action("Sign", "Sign", new { signerId = Model.Signer.Id } , Context.Request.Scheme, null),
        SignatureBoxes = new SignatureBox[] {
            new SignatureBox(Model.Signer.SignatureFieldName) {
                SigningRequired = true, Style = SignatureBox.SignatureBoxStyle.Signature }
        }
    };
}).Render()

Custom HTTP Endpoint

The custom controller HttpPost method Sign is called by the DocumentViewer after a document has been signed successfully and should implement the SignatureData object:

[HttpPost]
public IActionResult Sign([FromBody] SignatureData data, string signerId) {

DocumentFlow flow = new DocumentFlow(data.UniqueId);
   Signer signer = flow.Signers.Find(x => x.Id == signerId);

   signer.SignatureComplete = true;

   flow.Save();

   byte[] imageData = Convert.FromBase64String(data.SignatureImage);
   System.IO.File.WriteAllBytes("App_Data/documentflows/" + flow.EnvelopeId + "/signature_" + signer.Id + ".svg", imageData);

   bool allSigned = flow.Signers.All(y => y.SignatureComplete == true);

   if (allSigned == true) {

      using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) {
         tx.Create();

         // load the signed document
         tx.Load("App_Data/documentflows/" + flow.EnvelopeId + "/template.tx", TXTextControl.StreamType.InternalUnicodeFormat);

         List<TXTextControl.DigitalSignature> digitalSignatures = new List<DigitalSignature>();

         foreach (SignatureField field in tx.SignatureFields) {
            signer = flow.Signers.Find(x => x.SignatureFieldName == field.Name);
            field.Image = new SignatureImage("App_Data/documentflows/" + flow.EnvelopeId + "/signature_" + signer.Id + ".svg", 4);
            field.SignerData = new SignerData(signer.Name, "", "", "", "Text Control Signature Demo");

            // provide unique field name
            field.Name = field.Name + "_" + Guid.NewGuid().ToString();

            digitalSignatures.Add(new DigitalSignature(
               new System.Security.Cryptography.X509Certificates.X509Certificate2(
                  "App_Data/textcontrolself.pfx", "123"), null, field.Name));
          }

         SaveSettings saveSettings = new SaveSettings() {
            SignatureFields = digitalSignatures.ToArray()
         };

         tx.Save("App_Data/documentflows/" + flow.EnvelopeId + "/results.pdf", TXTextControl.StreamType.AdobePDF, saveSettings);

         flow.Closed = true;
         flow.Save();
      }
   }

   return Ok();
}

The forwarded SignatureData object contains meta data about the signature and the signed document:

Signature Workflow

After the user signed the document, the electronic signature is stored server-side until all signatures are acquired. After that, all signature images are patched to the document and finally, the document is signed digitally. The following sequence diagram shows the general workflow::

Signature Workflow

The Sample Application

After starting the sample application, an overview of all signature requests ("flows") is shown:

Signature Workflow

To create a new flow, click the button New Flow. This page is asking the user to upload a document that is used for the document signing process. For this demo, the document must be in the internal Text Control format.

Signature Workflow

The document is analyzed server-side for contained SignatureField objects with unique Names.

Signature Workflow

As the document owner, you can complete the form data for each signature field and create the document flow by clicking the button Create:

Signature Workflow

The overview list contains the created signature flow including links for the signers to request the signatures. In real-world applications, this link would be shared by e-mail or other ways. For demo purposes, you can now click on this link to complete the signatures:

Signature Workflow

After all parties have signed the document, the document is finalized and will be available for download in the overview:

Signature Workflow

You can clone the sample and test this workflow on your own. This sample is meant to be as a framework for your own workflows. The major advantage of the electronic signatures created with TX Text Control is the flexibility and the customization options.

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

GitHub

Download and Fork This Sample on GitHub

We proudly host our sample code on github.com/TextControl.

Please fork and contribute.

Download ZIP

Open on GitHub

Open in Visual Studio

Requirements for this sample

  • TX Text Control .NET Server 31.0
  • Visual Studio 2022

ASP.NET

Integrate document processing into your applications to create documents such as PDFs and MS Word documents, including client-side document editing, viewing, and electronic signatures.

ASP.NET Core
Angular
Blazor
JavaScript
React
  • Angular
  • Blazor
  • React
  • JavaScript
  • ASP.NET MVC, ASP.NET Core, and WebForms

Learn more Trial token Download trial

Related Posts

ASP.NETASP.NET CoreDocument Viewer

Securing the Signature Endpoint with Custom ActionFilterAttributes

The HttpPost endpoint to which the signed document is forwarded can be in the same application or a completely different application. This tutorial will show you how to secure this endpoint…


ASP.NETASP.NET CoreDocument Viewer

Common Web API Methods for Handling E-Signature Workflows in ASP.NET Core C#

Capturing electronic signatures and signing signature fields with certificates is a common feature of the TX Text Control Document Viewer. The most common server-side Web API methods for handling…


ASP.NETASP.NET CoreElectronic Signatures

Replace Words at the Input Position with Formatted Content from a Web API

Writing assistance and placeholder replacement are advanced features that help users create professional documents. This sample shows how to replace the word at the current input position with…


ASP.NETASP.NET CoreElectronic Signatures

Preparing Documents for Electronic Signatures using MailMerge in C#

There are many benefits to using MS Word compatible templates to prepare documents for electronic signature capture. This article shows how to use MailMerge to prepare documents for the signing…


ASP.NETASP.NET CoreElectronic Signatures

Advantages of Text Control Electronic Signatures

Electronic and digital signatures implemented through TX Text Control provide significant advantages over other concepts. This article gives an overview of advantages and differences of TX Text…