# Digitally Sign Signature Fields with PFX Certificates

> This getting started tutorial shows how to electronically sign documents using the Document Viewer and how to digitally sign the signed signature fields server-side.

- **Author:** Bjoern Meyer
- **Published:** 2022-09-13
- **Modified:** 2026-11-07
- **Description:** This getting started tutorial shows how to electronically sign documents using the Document Viewer and how to digitally sign the signed signature fields server-side.
- **3 min read** (470 words)
- **Tags:**
  - ASP.NET Core
  - Electronic Signatures
- **Web URL:** https://www.textcontrol.com/blog/2022/09/13/digitally-sign-signature-fields-with-pfx-certificates/
- **LLMs URL:** https://www.textcontrol.com/blog/2022/09/13/digitally-sign-signature-fields-with-pfx-certificates/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2022/09/13/digitally-sign-signature-fields-with-pfx-certificates/llms-full.txt
- **GitHub Repository:** https://github.com/TextControl/TextControl.Web.MVC.Core.SignCertificate

---

This article shows how to use the Document Viewer to acquire an electronic signature and to digitally sign the signature fields by routing the request to a custom controller method.

### Redirect URL

In version 31, a redirect URL can be provided using the RedirectUrlAfterSignature property that is used to forward the signature data from the integrated DocumentViewer server-side controller. The following code shows how to attach the custom controller method Home/SignDocument:

```
@Html.TXTextControl().DocumentViewer(settings => {
  settings.DocumentPath = "App_Data/template.docx";
  settings.Dock = DocumentViewerSettings.DockStyle.Fill;
  settings.ShowThumbnailPane = false;
  settings.SignatureSettings = new SignatureSettings() {
    ShowSignatureBar = true,
    OwnerName = "Paul Paulsen",
    SignerName = "Tim Typer",
    SignerInitials = "TT",
    RedirectUrlAfterSignature = this.Url.Action("SignDocument", "Home", null, Context.Request.Scheme, null),
    SignatureBoxes = new SignatureBox[] { 
      new SignatureBox("txsign") { 
      SigningRequired = true, Style = SignatureBox.SignatureBoxStyle.Signature }
  }};
}).Render()
```

The following screenshot shows the Document Viewer that is used to acquire the electronic signature (drawing) from the user:

![Document signing](https://s1-www.textcontrol.com/assets/dist/blog/2022/09/13/a/assets/acquisition.webp "Document signing")

### Custom Processing

After the user signed the document, the electronic signature is patched to the document and forwarded to the given URL including signature data such as the signature image and timestamp information. The following sequence diagram shows this workflow:

![Document signing sequence diagram](https://s1-www.textcontrol.com/assets/dist/blog/2022/09/13/a/assets/diagram3.webp "Document signing sequence diagram")

The implemented HttpPost endpoint *SignDocument* is requested by the Document Viewer after the signing process. In this method, a digital certificate is applied to the signed electronic signature representation using the SignatureFields property. This property specifies an array of DigitalSignature objects, each of which defines an X.509 certificate and is associated with a SignatureField in the document. These certificates can be used to digitally sign a PDF or a PDF/A file.

```
[HttpPost]
public string SignDocument([FromBody] TXTextControl.Web.MVC.DocumentViewer.Models.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);

    // create a certificate
    X509Certificate2 cert = new X509Certificate2("App_Data/textcontrolself.pfx", "123");

    // assign the certificate to the signature fields
    TXTextControl.SaveSettings saveSettings = new TXTextControl.SaveSettings() {
      CreatorApplication = "TX Text Control Sample Application",
      SignatureFields = new DigitalSignature[] {
        new TXTextControl.DigitalSignature(cert, null, "txsign")
      }
    };

    // save the document as PDF
    tx.Save(out bPDF, TXTextControl.BinaryStreamType.AdobePDFA, saveSettings);
  }

  // return as Base64 encoded string
  return Convert.ToBase64String(bPDF);
}
```

### Return Signed PDF

In this sample project, the created PDF document is returned as a Base64 encoded string. Whatever is returned by this endpoint is automatically forwarded to the client-side method specified through the setSubmitCallback method.

```
window.addEventListener("documentViewerLoaded", function () {
	TXDocumentViewer.signatures.setSubmitCallback(signatureComplete);
});

function signatureComplete(e) {
    var element = document.createElement('a');
    element.setAttribute('href','data:application/pdf;;base64,' + e);
    element.setAttribute('download', "results.pdf");
    document.body.appendChild(element);
    element.click();
}
```

---

## 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

- [Securing the Signature Endpoint with Custom ActionFilterAttributes](https://www.textcontrol.com/blog/2023/07/25/securing-the-signature-endpoint-with-custom-actionfilterattributes/llms.txt)
- [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.txt)
- [Replace Words at the Input Position with Formatted Content from a Web API](https://www.textcontrol.com/blog/2023/07/06/replace-words-at-the-input-position-with-formatted-content-from-a-web-api/llms.txt)
- [Preparing Documents for Electronic Signatures using MailMerge in C#](https://www.textcontrol.com/blog/2023/07/05/preparing-documents-for-electronic-signatures-using-mailmerge-in-csharp/llms.txt)
- [Electronic Signatures: Requesting Signatures from Multiple Signers using Custom Signature Workflows](https://www.textcontrol.com/blog/2023/01/02/electronic-signatures-requesting-signatures-from-multiple-signers-using-custom-signature-workflows/llms.txt)
- [Advantages of Text Control Electronic Signatures](https://www.textcontrol.com/blog/2022/11/22/advantages-of-text-control-electronic-signatures/llms.txt)
- [code.talks 2026: Two Fantastic Days of Developers, Innovation, and Great Conversations in Hamburg](https://www.textcontrol.com/blog/2026/11/06/code-talks-2026-hamburg/llms.txt)
- [React DOCX Editor: Add Word-Like Editing to Your Web App](https://www.textcontrol.com/blog/2026/11/04/how-to-add-react-docx-editor/llms.txt)
- [How to Embed a DOCX Editor in a Web Application (ASP.NET Core)](https://www.textcontrol.com/blog/2026/10/30/how-to-embed-docx-editor-aspnet-core/llms.txt)
- [DOCX Editor SDK: A Complete Evaluation Guide and Checklist](https://www.textcontrol.com/blog/2026/10/28/docx-editor-sdk-complete-evaluation-guide-and-checklist/llms.txt)
- [Meet Text Control at code.talks 2026: Spreadsheets, Documents, and More](https://www.textcontrol.com/blog/2026/10/27/meet-text-control-at-code-talks-2026/llms.txt)
- [Text Control Proudly Sponsors .NET Conf 2026](https://www.textcontrol.com/blog/2026/10/23/text-control-proudly-sponsors-dotnet-conf-2026/llms.txt)
- [Introducing TX Sheet Control: Excel Compatible Spreadsheets and Interactive Dashboards](https://www.textcontrol.com/blog/2026/10/23/introducing-tx-sheet-control-excel-compatible-spreadsheets-and-interactive-dashboards/llms.txt)
- [Convert DOCX to PDF, PDF/A and PDF/UA in C# Using TX Text Control](https://www.textcontrol.com/blog/2026/10/22/convert-docx-to-pdf-pdfa-and-pdfua-in-csharp-using-tx-text-control/llms.txt)
- [How to Extract Structured Data from Word Documents in C#](https://www.textcontrol.com/blog/2026/10/22/how-to-extract-structured-data-from-word-documents-in-csharp/llms.txt)
- [Reliable Document AI in .NET: LLM Tool Calling vs. LLM-Generated Files](https://www.textcontrol.com/blog/2026/10/14/reliable-document-ai-in-dotnet-llm-tool-calling-vs-llm-generated-files/llms.txt)
- [Building a Production-Ready PDF Generation Pipeline in C# with ASP.NET Core](https://www.textcontrol.com/blog/2026/10/12/reliable-pdf-generation-pipeline-csharp-aspnet-core/llms.txt)
- [BASTA! 2026: Why AI Makes Deep Technology More Important Than Ever](https://www.textcontrol.com/blog/2026/10/02/basta-2026-why-ai-makes-deep-technology-more-important-than-ever/llms.txt)
- [WeAreDevelopers World Congress North America 2026: A Strong Start in the United States](https://www.textcontrol.com/blog/2026/09/27/wearedevelopers-world-congress-north-america-2026/llms.txt)
- [Building Legal Document AI with TX Text Control: From RAG and Contract Analysis to AI-Assisted Editing](https://www.textcontrol.com/blog/2026/09/23/building-legal-document-ai-with-tx-text-control/llms.txt)
- [NDC Oslo 2026: Developers, Documents, and Private AI](https://www.textcontrol.com/blog/2026/09/21/ndc-oslo-2026-developers-documents-and-private-ai/llms.txt)
- [TX Text Control 34.0 SP5 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2026/09/14/tx-text-control-34-0-sp5-is-now-available/llms.txt)
- [Introducing TX Text Control AI: Private AI for Real Document Workflows in .NET C#](https://www.textcontrol.com/blog/2026/09/09/introducing-tx-text-control-ai-private-ai-for-real-document-workflows-in-dot-net-c-sharp/llms.txt)
- [Meet Us at BASTA! Mainz: Demos, Talks and More](https://www.textcontrol.com/blog/2026/08/31/meet-us-at-basta-mainz-demos-talks-and-more/llms.txt)
- [From Classification to Data Extraction: New Document Analysis Samples](https://www.textcontrol.com/blog/2026/08/31/from-classification-to-data-extraction-new-document-analysis-samples/llms.txt)
