# Apply Digital Signatures to PDF Signature Fields Imported from MS Word in C#

> Signature fields can be created and imported from MS Word documents such as DOCX. They can be processed by TX Text Control and applied to a PDF document. The necessary steps are explained in this article.

- **Author:** Bjoern Meyer
- **Published:** 2023-08-25
- **Modified:** 2025-11-16
- **Description:** Signature fields can be created and imported from MS Word documents such as DOCX. They can be processed by TX Text Control and applied to a PDF document. The necessary steps are explained in this article.
- **5 min read** (852 words)
- **Tags:**
  - ASP.NET Core
  - Electronic Signature
  - Document Viewer
  - ServerTextControl
- **Web URL:** https://www.textcontrol.com/blog/2023/08/25/apply-digital-signatures-to-pdf-signature-fields-imported-from-ms-word-in-csharp/
- **LLMs URL:** https://www.textcontrol.com/blog/2023/08/25/apply-digital-signatures-to-pdf-signature-fields-imported-from-ms-word-in-csharp/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2023/08/25/apply-digital-signatures-to-pdf-signature-fields-imported-from-ms-word-in-csharp/llms-full.txt

---

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 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](https://s1-www.textcontrol.com/assets/dist/blog/2023/08/25/a/assets/step1.webp "Signature Fields")

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

![Signature Fields](https://s1-www.textcontrol.com/assets/dist/blog/2023/08/25/a/assets/step2.webp "Signature Fields")

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

![Signature Fields](https://s1-www.textcontrol.com/assets/dist/blog/2023/08/25/a/assets/step3.webp "Signature Fields")

### Adding Additional Information

When signing PDF documents, TX Text Control provides additional SignerData 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);
}
```

### 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()
```

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

![Signature Fields](https://s1-www.textcontrol.com/assets/dist/blog/2023/08/25/a/assets/viewer.webp "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# ](https://www.textcontrol.com/blog/2023/07/20/common-web-api-methods-for-handling-esignature-workflows-in-aspnet-core-csharp/llms-full.txt)

The following HttpPost method loads the signed document and applies a certificate to each of the signature fields by going through the SignatureBoxes 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();
}
```

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](https://s1-www.textcontrol.com/assets/dist/blog/2023/08/25/a/assets/results.webp "Signature Fields")

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)

---

## Related Posts

- [Sign Documents with a Self-Signed Digital ID From Adobe Acrobat Reader in .NET C#](https://www.textcontrol.com/blog/2024/08/12/sign-documents-with-a-self-signed-digital-id-from-adobe-acrobat-reader-in-net-c-sharp/llms.txt)
- [Getting Started Video Tutorial: How to Add Electronic and Digital Signatures to PDF Documents in ASP.NET Core C#](https://www.textcontrol.com/blog/2024/08/05/getting-started-video-tutorial-how-to-add-electronic-and-digital-signatures-to-pdf-documents-in-asp-net-core-csharp/llms.txt)
- [Transforming Financial Documents into Smart and Secure Forms in ASP.NET Core C#](https://www.textcontrol.com/blog/2024/05/01/transforming-financial-documents-into-smart-and-secure-forms-in-asp-net-core-c-sharp/llms.txt)
- [How to Add Electronic and Digital Signatures to PDFs in ASP.NET Core C# and Angular](https://www.textcontrol.com/blog/2024/03/20/how-to-add-electronic-and-digital-signatures-to-pdfs-in-asp-net-core-c-sharp-and-angular/llms.txt)
- [High-Performance Text Replacement in Large DOCX Files using C# .NET](https://www.textcontrol.com/blog/2025/07/30/high-performance-text-replacement-in-large-docx-files-using-csharp-dotnet/llms.txt)
- [Document Viewer 33.2.1 Released: New Event and Bug Fixes](https://www.textcontrol.com/blog/2025/07/30/document-viewer-33-2-1-released-new-event-and-bug-fixes/llms.txt)
- [E-Sign Comes to Blazor: Document Viewer 33.0.1 Released](https://www.textcontrol.com/blog/2025/04/24/e-sign-comes-to-blazor-document-viewer-33-0-1-released/llms.txt)
- [Adoption of Electronic vs. Paper Signatures in 2025](https://www.textcontrol.com/blog/2025/04/15/adoption-of-electronic-vs-paper-signatures-in-2025/llms.txt)
- [Building an ASP.NET Core Backend (Linux and Windows) for the Document Editor and Viewer](https://www.textcontrol.com/blog/2025/03/26/building-an-asp-net-core-backend-for-the-document-editor-and-viewer/llms.txt)
- [TX Text Control Document Editor and Viewer for Blazor Released](https://www.textcontrol.com/blog/2025/03/25/tx-text-control-document-editor-and-viewer-for-blazor-released/llms.txt)
- [Getting Started: Document Viewer for Blazor in ASP.NET Core](https://www.textcontrol.com/blog/2025/03/25/getting-started-document-viewer-for-blazor-in-asp-net-core/llms.txt)
- [Getting Started: Document Viewer with ASP.NET Core and Linux WSL Support](https://www.textcontrol.com/blog/2025/03/12/getting-started-document-viewer-with-asp-net-core-and-linux-wsl-support/llms.txt)
- [Announcing Our Work on a Blazor Component for Document Editing and Viewing](https://www.textcontrol.com/blog/2025/01/24/announcing-our-work-on-a-blazor-component-for-document-editing-and-viewing/llms.txt)
- [The Importance of PDF Signing in .NET C#](https://www.textcontrol.com/blog/2025/01/14/the-importance-of-pdf-signing-in-net-csharp/llms.txt)
- [Preparing Documents for E-Signing for Multiple Signers in .NET C#](https://www.textcontrol.com/blog/2024/11/13/preparing-documents-for-e-signing-for-multiple-signers-in-net-c-sharp/llms.txt)
- [ASP.NET Core: Use the Document Editor and Viewer in the Same Razor View](https://www.textcontrol.com/blog/2024/11/08/asp-net-core-use-the-document-editor-and-viewer-in-the-same-razor-view/llms.txt)
- [When to Generate Documents Server-Side Instead of Client-Side: A Focus on Data Security](https://www.textcontrol.com/blog/2024/10/04/when-to-generate-documents-server-side-instead-of-client-side-a-focus-on-data-security/llms.txt)
- [Optimizing Digital Signature Workflows: Starting with MS Word DOCX Files Instead of PDFs in C#](https://www.textcontrol.com/blog/2024/09/27/optimizing-digital-signature-workflows-starting-with-ms-word-docx-files-instead-of-pdfs-in-csharp/llms.txt)
- [Document Viewer: Setting the Rendering Mode](https://www.textcontrol.com/blog/2024/08/22/document-viewer-setting-the-rendering-mode/llms.txt)
- [Programmatically Convert MS Word DOCX Documents to PDF in .NET C#](https://www.textcontrol.com/blog/2024/08/09/programmatically-convert-ms-word-docx-documents-to-pdf-in-net-c-sharp/llms.txt)
- [View MS Word DOCX and PDF Documents using a .NET C# Document Viewer for ASP.NET Core and ASP.NET](https://www.textcontrol.com/blog/2024/08/08/view-ms-word-docx-and-pdf-documents-using-a-net-csharp-document-viewer-for-aspnet-core-and-aspnet/llms.txt)
- [Low Code vs. High Code: Differences between TX Text Control and DS Server](https://www.textcontrol.com/blog/2024/08/07/low-code-vs-high-code-differences-between-tx-text-control-and-ds-server/llms.txt)
- [Getting Started Video Tutorial: How to use the Document Viewer in Angular](https://www.textcontrol.com/blog/2024/08/05/getting-started-video-tutorial-how-to-use-the-document-viewer-in-angular/llms.txt)
- [Getting Started Video Tutorial: How to use the MailMerge and ServerTextControl Classes in ASP.NET Core C#](https://www.textcontrol.com/blog/2024/08/05/getting-started-video-tutorial-how-to-use-the-mailmerge-and-servertextcontrol-classes-in-asp-net-core-c/llms.txt)
- [Getting Started Video Tutorial: How to use the Document Viewer in ASP.NET Core C#](https://www.textcontrol.com/blog/2024/08/05/getting-started-video-tutorial-how-to-use-the-document-viewer-in-asp-net-core-csharp/llms.txt)
