# Adding Digital Signatures to PDF Documents in C#

> Using TX Text Control, adding digital and electronic signatures to documents is an easy task. This article shows how to sign the complete document with a digital certificate and how to sign individual signature fields.

- **Author:** Bjoern Meyer
- **Published:** 2022-11-29
- **Modified:** 2025-11-16
- **Description:** Using TX Text Control, adding digital and electronic signatures to documents is an easy task. This article shows how to sign the complete document with a digital certificate and how to sign individual signature fields.
- **4 min read** (755 words)
- **Tags:**
  - ASP.NET
  - ASP.NET Core
  - PDF
  - Digital Signing
- **Web URL:** https://www.textcontrol.com/blog/2022/11/29/adding-digital-signatures-to-pdf-documents-in-csharp/
- **LLMs URL:** https://www.textcontrol.com/blog/2022/11/29/adding-digital-signatures-to-pdf-documents-in-csharp/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2022/11/29/adding-digital-signatures-to-pdf-documents-in-csharp/llms-full.txt

---

The Adobe PDF document format is used in many types of documents including data with a legal value such as in agreements and contracts. Documents can be digitally signed to ensure that a document has not been altered by a third-party and to verify that the author is the expected person.

A digital signature use the concept of hashing - a mathematical function that converts a block of data into a fixed-size string. The result of this function is always identical for this block of data, if the data block has not been altered.

This hash function is used on almost all elements of a document and is then stored inside the document.

When signing Adobe PDF documents with TX Text Control, there are two different approaches:

- Sign the whole document with a digital certificate
- Sign individual signature fields with a digital certificate(s)

Technically, a visual representation of the signature compared to wet ink is not required to sign a document. But in many cases, an electronic signature that is captured using the [TX Text Control Document Viewer](https://www.textcontrol.com/blog/2022/09/13/digitally-sign-signature-fields-with-pfx-certificates/llms-full.txt), can be signed with a digital certificate.

### Signing the Document

The first method shows how to digitally sign the complete document with one certificate. The signatures can be created with PFX, DER Cer or Base64 CER certificate files. Additionally, certificates can be loaded from raw data or selected from the local certificate store. The digital signature and the signed PDF document are cryptographically bound and secured which guarantees that the document has not been tampered.

Typically, the document signing process is a server-side task that gives a safe place to access the certificate with the private key. The following method uses the ServerTextControl class to create a document in order to export the document as PDF. During the saving process, the digital signature is applied using the SaveSettings.DigitalSignature property.

```
public static void SignDocument() {

  using (ServerTextControl tx = new ServerTextControl()) {

    tx.Create();

    // add dummy text
    tx.Text = "This is a signed document";

    SaveSettings saveSettings = new SaveSettings();

    // add digital signature to sign complete document
    saveSettings.DigitalSignature = new DigitalSignature(
      new System.Security.Cryptography.X509Certificates.X509Certificate2(
        "textcontrolself.pfx", "123"), null);

    // export to PDF
    tx.Save("signed_documents.pdf", StreamType.AdobePDF, saveSettings);
  }

}
```

When opening the created PDF document in Acrobat Reader, the digital signature is recognized and shows an invisible signature field.

![Signing a PDF document](https://s1-www.textcontrol.com/assets/dist/blog/2022/11/29/b/assets/document_signature.webp "Signing a PDF document")

### Signing Signature Fields

In the second 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.

In the following code snipped, a signature field is added to a new document and an SVG image is added as the visual signature representation. The created digital signature is associated with the signature field and then provided by the *SaveSettings* to export the document as an Adobe PDF document.

```
public static void SignFields() {
  using (ServerTextControl tx = new ServerTextControl()) {

    tx.Create();

    // create a signature field
    SignatureField signatureField = new SignatureField(
      new System.Drawing.Size(2000, 2000), "txsign", 10);

    // set image representation
    signatureField.Image = new SignatureImage("signature.svg", 0);

    // insert the field
    tx.SignatureFields.Add(signatureField, -1);

    // create a digital signature (for each field, if required)
    DigitalSignature digitalSignature = new DigitalSignature(
      new System.Security.Cryptography.X509Certificates.X509Certificate2(
        "textcontrolself.pfx", "123"), null, "txsign");

    // apply the signatures to the SaveSettings
    SaveSettings saveSettings = new SaveSettings() {
      SignatureFields = new DigitalSignature[] { digitalSignature }
    };

    // export to PDF
    tx.Save("signed_fields.pdf", StreamType.AdobePDF, saveSettings);
  }
}
```

When loading this document into Acrobat Reader, the signature field is shown as a visual representation in the document. If you click on that field, a dialog confirms the validation status. Additionally, the signature field name is shown in the sidebar.

![Signing a PDF document](https://s1-www.textcontrol.com/assets/dist/blog/2022/11/29/b/assets/document_fields.webp "Signing a PDF document")

When specifying additional properties to the signature field, those values are displayed in the signature details in Acrobat Reader:

```
// create a signature field
SignatureField signatureField = new SignatureField(
  new System.Drawing.Size(2000, 2000), "txsign", 10) {
  Image = new SignatureImage("signature.svg", 0),
  SignerData = new SignerData(
    "Tim Typer", 
    "Developer", 
    "5652 Text Control Dr", 
    "tim@textcontrol.com",
    "Contract signature")
};
```

![Signing a PDF document](https://s1-www.textcontrol.com/assets/dist/blog/2022/11/29/b/assets/document_fields_properties.webp "Signing a PDF document")

---

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

- [Digitally Signing Adobe PDF Documents](https://www.textcontrol.com/blog/2022/09/15/digitally-signing-adobe-pdf-documents/llms.txt)
- [Why Structured E-Invoices Still Need Tamper Protection using C# and .NET](https://www.textcontrol.com/blog/2026/03/24/why-structured-e-invoices-still-need-tamper-protection-using-csharp-and-dotnet/llms.txt)
- [Create Fillable PDFs from HTML Forms in C# ASP.NET Core Using a WYSIWYG Template](https://www.textcontrol.com/blog/2026/03/17/create-fillable-pdfs-from-html-forms-in-csharp-aspnet-core-using-a-wysiwyg-template/llms.txt)
- [Why HTML to PDF Conversion is Often the Wrong Choice for Business Documents in C# .NET](https://www.textcontrol.com/blog/2026/03/13/why-html-to-pdf-conversion-is-often-the-wrong-choice-for-business-documents-in-csharp-dot-net/llms.txt)
- [A Complete Guide to Converting Markdown to PDF in .NET C#](https://www.textcontrol.com/blog/2026/01/07/a-complete-guide-to-converting-markdown-to-pdf-in-dotnet-csharp/llms.txt)
- [Why PDF Creation Belongs at the End of the Business Process](https://www.textcontrol.com/blog/2026/01/02/why-pdf-creation-belongs-at-the-end-of-the-business-process/llms.txt)
- [Designing the Perfect PDF Form with TX Text Control in .NET C#](https://www.textcontrol.com/blog/2025/12/16/designing-the-perfect-pdf-form-with-tx-text-control-in-dotnet-csharp/llms.txt)
- [Why Defining MIME Types for PDF/A Attachments Is Essential](https://www.textcontrol.com/blog/2025/12/10/why-defining-mime-types-for-pdfa-attachments-is-essential/llms.txt)
- [Validate Digital Signatures and the Integrity of PDF Documents in C# .NET](https://www.textcontrol.com/blog/2025/11/14/validate-digital-signatures-and-the-integrity-of-pdf-documents-in-csharp-dotnet/llms.txt)
- [Validate PDF/UA Documents and Verify Electronic Signatures in C# .NET](https://www.textcontrol.com/blog/2025/11/13/validate-pdf-ua-documents-and-verify-electronic-signatures-in-csharp-dotnet/llms.txt)
- [How To Choose the Right C# PDF Generation Library: Developer Checklist](https://www.textcontrol.com/blog/2025/11/12/how-to-choose-the-right-csharp-pdf-generation-library-developer-checklist/llms.txt)
- [Why Digitally Signing your PDFs is the Only Reliable Way to Prevent Tampering](https://www.textcontrol.com/blog/2025/10/30/why-digitally-signing-your-pdfs-is-the-only-reliable-way-to-prevent-tampering/llms.txt)
- [Automating PDF/UA Accessibility with AI: Describing DOCX Documents Using TX Text Control and LLMs](https://www.textcontrol.com/blog/2025/10/16/automating-pdf-ua-accessibility-with-ai-describing-docx-documents-using-tx-text-control-and-llms/llms.txt)
- [Converting Office Open XML (DOCX) to PDF in Java](https://www.textcontrol.com/blog/2025/10/14/converting-office-open-xml-docx-to-pdf-in-java/llms.txt)
- [Extending DS Server with Custom Digital Signature APIs](https://www.textcontrol.com/blog/2025/10/09/extending-ds-server-with-custom-digital-signature-apis/llms.txt)
- [Why PDF/UA and PDF/A-3a Matter: Accessibility, Archiving, and Legal Compliance](https://www.textcontrol.com/blog/2025/10/07/why-pdf-ua-and-pdf-a-3a-matter-accessibility-archiving-and-legal-compliance/llms.txt)
- [Convert Markdown to PDF in a Console Application on Linux and Windows](https://www.textcontrol.com/blog/2025/09/23/convert-markdown-to-pdf-in-a-console-application-on-linux-and-windows/llms.txt)
- [Mining PDFs with Regex in C#: Practical Patterns, Tips, and Ideas](https://www.textcontrol.com/blog/2025/08/12/mining-pdfs-with-regex-in-csharp-practical-patterns-tips-and-ideas/llms.txt)
- [Streamline Data Collection with Embedded Forms in C# .NET](https://www.textcontrol.com/blog/2025/08/02/streamline-data-collection-with-embedded-forms-in-csharp-dotnet/llms.txt)
- [Adding QR Codes to PDF Documents in C# .NET](https://www.textcontrol.com/blog/2025/07/15/adding-qr-codes-to-pdf-documents-in-csharp-dotnet/llms.txt)
- [Adding SVG Graphics to PDF Documents in C# .NET](https://www.textcontrol.com/blog/2025/07/08/adding-svg-graphics-to-pdf-documents-in-csharp-dotnet/llms.txt)
- [Enhancing PDF Searchability in Large Repositories by Adding and Reading Keywords Using C# .NET](https://www.textcontrol.com/blog/2025/06/24/enhancing-pdf-searchability-in-large-repositories-by-adding-and-reading-keywords-using-csharp-dotnet/llms.txt)
- [How to Verify PDF Encryption Programmatically in C# .NET](https://www.textcontrol.com/blog/2025/06/20/how-to-verify-pdf-encryption-programmatically-in-csharp-dotnet/llms.txt)
- [PDF Security for C# Developers: Encryption and Permissions in .NET](https://www.textcontrol.com/blog/2025/06/16/pdf-security-for-csharp-developers-encryption-and-permissions-in-dotnet/llms.txt)
- [Add JavaScript to PDFs with TX Text Control in C# .NET: Time-Based Alerts Made Easy](https://www.textcontrol.com/blog/2025/06/13/add-javascript-to-pdfs-with-tx-text-control-in-c-dot-net-time-based-alerts-made-easy/llms.txt)
