# Handling Electronic Signatures in a Blazor Web App using .NET 8

> This article shows how to create a Blazor Web App that uses the TX Text Control Document Viewer to display documents and how to handle electronic signatures using the TX Text Control signature API.

- **Author:** Bjoern Meyer
- **Published:** 2024-02-06
- **Modified:** 2026-07-17
- **Description:** This article shows how to create a Blazor Web App that uses the TX Text Control Document Viewer to display documents and how to handle electronic signatures using the TX Text Control signature API.
- **3 min read** (539 words)
- **Tags:**
  - ASP.NET
  - .NET 8
  - Blazor
  - Document Viewer
  - Electronic Signature
- **Web URL:** https://www.textcontrol.com/blog/2024/02/06/handling-electronic-signatures-in-a-blazor-web-app-using-net-8/
- **LLMs URL:** https://www.textcontrol.com/blog/2024/02/06/handling-electronic-signatures-in-a-blazor-web-app-using-net-8/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2024/02/06/handling-electronic-signatures-in-a-blazor-web-app-using-net-8/llms-full.txt
- **GitHub Repository:** https://github.com/TextControl/TXTextControl.Server.Blazor.Viewer.Signature

---

The TX Text Control Document Viewer can be used in a Blazor Web App in server-side rendering mode. .NET 8 allows you to control the rendering mode by component. The whole concept and how to create a new Blazor Web App using the TX Text Control Document Viewer can be found in the article below.

> **Learn More**
> 
> This article shows how to use the Document Viewer in a Blazor Server application with .NET 8. The Document Viewer is a powerful, web-based document viewer that can be easily integrated into any Blazor application.
> 
> [Using the Document Viewer in a Blazor Server App with .NET 8 ](https://www.textcontrol.com/blog/2024/01/29/using-the-document-viewer-in-a-blazor-server-app-with-net-8/llms-full.txt)

### SignatureSettings Object

This example is based on such a tutorial project, but it implements the workflow of an electronic signature acquisition process. The example uses the same structure to load documents, but this time with *SignatureSettings* to enable the signature mode.

The following implementation of LoadDocumentFromFile uses a *SignatureSettings* object to set the signature settings for the document being signed.

```
[JSInvokable("LoadDocumentFromFile")]
public void LoadDocumentFromFile(string filename)
{
	// check if the file exists
	if (!System.IO.File.Exists(filename))
	{
		return;
	}

	// load the file into a byte array
	byte[] bDocument = System.IO.File.ReadAllBytes(filename);

	SignatureSettings signatureSettings = new SignatureSettings()
	{
		OwnerName = "John Doe",
		RedirectUrlAfterSignature = this.BasePath + "Signature/SignDocument",
		UniqueId = Guid.NewGuid().ToString(),
		SignerName = "Jane Doe",
		SignatureBoxes = new SignatureBox[]
		{
			new SignatureBox("txsign")
			{
				Style = SignatureBox.SignatureBoxStyle.Signature
			}
		},
		ShowSignatureBar = true		
	};

	// invoke the JS function 'loadDocument' to load back to the modified document
	_txdocumentviewer?.InvokeVoidAsync("loadDocument", new object[] { Convert.ToBase64String(bDocument), filename, BasePath, signatureSettings });
}
```

The *RedirectUrlAfterSignature* property is set to a controller that is part of the implementation of the Razor Web App. A sample document with a signature field is loaded after clicking the *Load Document* button.

![TX Text Control in Blazor](https://s1-www.textcontrol.com/assets/dist/blog/2024/02/06/a/assets/razor1.webp "TX Text Control in Blazor")

### Controller Web API

After signing and submitting, the document is signed and forwarded to the specified controller method.

![TX Text Control in Blazor](https://s1-www.textcontrol.com/assets/dist/blog/2024/02/06/a/assets/razor2.webp "TX Text Control in Blazor")

The controller method loads the signed document, which is returned in the internal TX Text Control format, signs the signature fields by applying a digital certificate, and exports the document as a PDF.

```
[ApiController]
[Route("signature")]
public class SignatureController : Controller
{
	[HttpPost("SignDocument")]
	public ActionResult SignDocument([FromBody] SignatureData signatureData)
	{
		byte[] bPDF;

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

			// load the document
			tx.Load(Convert.FromBase64String(signatureData.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 Blazor Sample Application",
				SignatureFields = new DigitalSignature[] {
					new TXTextControl.DigitalSignature(cert, null, "txsign")
				}
			};

			// save the document as PDF
			tx.Save("App_Data/results_" + signatureData.UniqueId + ".pdf", TXTextControl.StreamType.AdobePDF, saveSettings);
		}

		return Ok();
	}
}
```

### PDF Creation

The PDF document is then stored on the server in the App\_Data folder.

![TX Text Control in Blazor](https://s1-www.textcontrol.com/assets/dist/blog/2024/02/06/a/assets/razor3.webp "TX Text Control in Blazor")

Visit our GitHub repository to download and review the full application.

---

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

- [Using the Document Viewer in a Blazor Server App with .NET 8](https://www.textcontrol.com/blog/2024/01/29/using-the-document-viewer-in-a-blazor-server-app-with-net-8/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)
- [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)
- [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)
- [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)
- [Using TX Text Control in a Blazor Server App with .NET 8](https://www.textcontrol.com/blog/2024/01/25/using-tx-text-control-in-an-blazor-server-app-with-net-8/llms.txt)
- [What is the Difference between Electronic and Digital Signatures?](https://www.textcontrol.com/blog/2022/10/20/what-is-the-difference-between-electronic-and-digital-signatures/llms.txt)
- [Using Multiple Electronic Signatures on a Document](https://www.textcontrol.com/blog/2019/10/23/using-multiple-electronic-signatures/llms.txt)
