TX Text Control provides all of the parts and processes needed to implement electronic (digital) signatures on PDF documents. From the dynamic creation of templates with signature fields, to the collection of signatures from end users, to the digital signing of PDF documents.

Creating Signature Lines in MS Word

The TX Text Control SignatureField TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
SignatureField Class
An instance of the SignatureField class represents a signature field in a Text Control document.
objects are compatible with the SignatureLine element in MS Word. To create a document in MS Word that contains a signature line, use the Signature Line button in the Text ribbon group of the Insert ribbon tab.

Signature Fields

Additional information can be added to the signature line in the opened dialog.

Signature Fields

The created signature line will look like the one shown in the following screenshot.

Signature Fields

Adding Additional Information

When signing PDF documents, TX Text Control provides additional SignerData TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
SignerData Class
An instance of the SignerData class represents the data of a suggested signer connected with a SignatureField.
properties for PDF compatibility.

Property Description
Address Gets the address of a suggested signer.
ContactInfo Gets contact information of a suggested signer, such as a phone number.
Name Gets the name of a suggested signer.
Reason Gets a reason why the document is signed.
Title Gets the title of a suggested signer.

The following code shows how to load the Office Open XML MS Word document and add additional properties to the SignerData.

using (TXTextControl.ServerTextControl tx = new ServerTextControl())
{
tx.Create();
tx.Load("template.docx", TXTextControl.StreamType.WordprocessingML);
foreach (SignatureField field in tx.SignatureFields)
{
var signerData = field.SignerData;
field.SignerData = new SignerData(field.SignerData.Name,
field.SignerData.Title,
"Test",
field.SignerData.ContactInfo,
"Contract verification");
}
tx.Save("template_changed.tx", TXTextControl.StreamType.InternalUnicodeFormat);
}
view raw test.cs hosted with ❤ by GitHub

Acquiring the Signature

The Document Viewer is used to capture the user's electronic signature. The following code combines the setting of additional signer data and adds the signature fields to the active signature fields of the Document Viewer. In order to make the code readable for this article, everything will be placed in Razor code.

@using TXTextControl.Web.MVC.DocumentViewer
@{
byte[] documentArray;
List<SignatureBox> signatureBoxes = new List<SignatureBox>();
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
{
tx.Create();
tx.Load("App_Data\\template.docx", TXTextControl.StreamType.WordprocessingML);
// loop through all signature fields and set the signer data
foreach (TXTextControl.SignatureField field in tx.SignatureFields)
{
var signerData = field.SignerData;
field.SignerData = new TXTextControl.SignerData(field.SignerData.Name,
field.SignerData.Title,
"Test",
field.SignerData.ContactInfo,
"Contract verification");
// add a signature box to the document viewer
signatureBoxes.Add(new SignatureBox(field.Name) { SigningRequired = true, Style = SignatureBox.SignatureBoxStyle.Signature });
}
// save the document
tx.Save(out documentArray, TXTextControl.BinaryStreamType.InternalUnicodeFormat);
}
}
@Html.TXTextControl().DocumentViewer(settings => {
settings.DocumentData = Convert.ToBase64String(documentArray);
settings.SignatureSettings = new SignatureSettings() {
ShowSignatureBar = true,
OwnerName = "Josh Jackson",
SignerName = "Tim Typer",
SignerInitials = "TT",
UniqueId = "12345-12345-12345-12345",
RedirectUrlAfterSignature = this.Url.Action(
"HandleSignature",
"Signature",
null,
Context.Request.Scheme,
null),
SignatureBoxes = signatureBoxes.ToArray()
};
}).Render()
view raw test.cshtml hosted with ❤ by GitHub

The included signature field is converted into a signature box for the user to sign the document.

Signature Fields

Signing Signature Fields

After the user has signed the document, the electronic signature is attached to the document and forwarded to the specified URL, along with the signature data, such as the signature image and the time stamp information.

Learn More

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 electronic signatures are described in this article.

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

The following HttpPost method loads the signed document and applies a certificate to each of the signature fields by going through the SignatureBoxes TX Text Control .NET Server for ASP.NET
Web.MVC.DocumentViewer Namespace
SignatureBox Class
The SignatureBox class represents the shown signature box in the UI.
in a loop.

[HttpPost]
public IActionResult HandleSignature([FromBody] SignatureData data) {
byte[] bPDF;
// create temporary ServerTextControl
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) {
tx.Create();
// load the document
tx.Load(Convert.FromBase64String(data.SignedDocument.Document),
TXTextControl.BinaryStreamType.InternalUnicodeFormat);
X509Certificate2 cert = new X509Certificate2("App_Data/textcontrolself.pfx", "123");
var signatureFields = new List<DigitalSignature>();
foreach (SignatureBox box in data.SignatureBoxes) {
signatureFields.Add(new DigitalSignature(cert, null, box.Name));
}
TXTextControl.SaveSettings saveSettings = new TXTextControl.SaveSettings() {
CreatorApplication = "Your Application",
SignatureFields = signatureFields.ToArray()
};
// store the PDF in the database or send it to the client
tx.Save(out bPDF, TXTextControl.BinaryStreamType.AdobePDFA, saveSettings);
// alternatively, save the PDF to a file
tx.Save("App_Data/signed.pdf", TXTextControl.StreamType.AdobePDFA, saveSettings);
}
// return any value to the client
return Ok();
}
view raw test.cs hosted with ❤ by GitHub

All signature fields are digitally signed as a result of this implementation. The following screenshot shows the PDF file as it opens in Adobe Acrobat Reader and shows the valid signature field with the properties of the custom signer data. The created version of the document carries a digital signature that verifies that no tampering occurred after the document was created.

Signature Fields