Digitally Signing Adobe PDF Documents
Using TX Text Control, there are two ways of signing PDF documents: The whole document and individual signature fields. This article shows how to implement both ways in a .NET 6 command line application.

The Adobe PDF document format is used to share all kinds of information including data with a legal value such as in contracts or invoices. To ensure that a document has not been altered by a third-party and to verify that the author is the expected person, documents can be digitally signed.
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, 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, can be signed with a digital certificate.
This article shows how to implement both ways in a .NET 6 command line application.
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.
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);
}
}
A Digital
When opening the created PDF document in Acrobat Reader, the digital signature is recognized and shows an invisible signature field.

Signing Signature Fields
In the second method, a digital certificate is applied to the signed electronic signature representation using the Signature
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.

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")
};

![]()
Download and Fork This Sample on GitHub
We proudly host our sample code on github.com/TextControl.
Please fork and contribute.
Requirements for this sample
- TX Text Control .NET Server 31.0
- Visual Studio 2022
ASP.NET
Integrate document processing into your applications to create documents such as PDFs and MS Word documents, including client-side document editing, viewing, and electronic signatures.
- Angular
- Blazor
- React
- JavaScript
- ASP.NET MVC, ASP.NET Core, and WebForms
Related Posts
ASP.NETASP.NET CoreDigital Signing
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…
Why Defining MIME Types for PDF/A Attachments Is Essential
The PDF/A standard was created to ensure the long-term reliable archiving of digital documents. An important aspect of the standard involves properly handling embedded files and attachments within…
Validate Digital Signatures and the Integrity of PDF Documents in C# .NET
Learn how to validate digital signatures and the integrity of PDF documents using the PDF Validation component from TX Text Control in C# .NET. Ensure the authenticity and compliance of your…
Validate PDF/UA Documents and Verify Electronic Signatures in C# .NET
The new TXTextControl.PDF.Validation NuGet package enables you to validate PDF/UA documents and verify digital signatures directly in your code without relying on third-party tools or external…
How To Choose the Right C# PDF Generation Library: Developer Checklist
To make your choice easy, this guide provides a systematic evaluation framework for two library categories: basic and enterprise PDF libraries. It covers matching features to use cases, evaluating…
