SignatureField
The SignatureField class corresponds to FormFieldType.Signature and stores digital signature data. Use it to sign PDF documents or validate existing signatures.
To use the signing functionality in RadPdfProcessing for .NET Standard/.NET Core, you must add a reference to the
System.Security.Cryptography.PkcsNuGet package, version 9.0.9 or later. This functionality is available starting with R1 2022 SP1.
Properties
The SignatureField class provides the following properties:
| Property | Description |
|---|---|
Signature | Gets or sets the Signature value. Setting this property signs the document during export. Signing with multiple signatures is not supported. To validate a signature, use the Validate() and TryValidate() methods. Validation requires that the source stream is open and is performed against the document state at import time. See Digital Signature for more details. |
LockSettings | Gets the SignatureFieldLock settings that control which form fields become read-only after this signature field is signed. Returns null when no lock settings exist. |
Widgets | The collection of Widget annotations representing the field on the PDF pages. Widgets can be added using AddWidget() and removed using Remove(). Implements IEnumerable. |
Create a SignatureField and Add It to a Page
RadFixedDocument document = new RadFixedDocument();
X509Certificate2 certificate = new X509Certificate2("JohnDoe.pfx", "johndoe");
SignatureField signatureField = new SignatureField("SampleSignature");
signatureField.Signature = new Signature(certificate); // The Signature property fo SignatureField is not available in PdfProcessing for .NET Standard.
SignatureWidget widget = signatureField.Widgets.AddWidget();
widget.Rect = new Rect(200, 600, 100, 100);
widget.Border = new AnnotationBorder(5, AnnotationBorderStyle.Solid, null);
//Create a Form object to define the appearance you would like for the signature field.
Telerik.Documents.Fixed.Model.Objects.Form form = new Telerik.Documents.Fixed.Model.Objects.Form();
form.FormSource = new FormSource();
form.FormSource.Size = new Size(120, 120);
FixedContentEditor formEditor = new FixedContentEditor(form.FormSource);
formEditor.DrawCircle(new Point(50, 50), 20);
formEditor.DrawText("Sample Signature");
//Add the FormSource object to the widget of the field.
widget.Content.NormalContentSource = form.FormSource;
RadFixedPage page = document.Pages.Last();
page.Annotations.Add(widget);
document.AcroForm.FormFields.Add(signatureField);
Locking Fields After Signing
Before you sign, configure the lock on SignatureField, not Signature.Settings. Each method replaces the previous configuration with the corresponding SignatureFieldLockAction:
| Method | Action | Result after signing |
|---|---|---|
LockAllFields() | All | Locks every form field in the document. |
LockFields(IEnumerable<string> fieldNames) | Include | Locks only the named fields. An empty sequence locks no fields. |
LockAllFieldsExcept(IEnumerable<string> fieldNames) | Exclude | Locks every form field except the named fields. An empty sequence locks all fields. |
Use case-sensitive FormField.Name values. Both list-based methods copy the names, so later input changes have no effect. A null collection or field name throws ArgumentNullException.
This example configures the approval signature to lock customer details and leave ReviewerComment unaffected:
Telerik.Documents.Fixed.Model.RadFixedDocument document =
new Telerik.Documents.Fixed.Model.RadFixedDocument();
document.Pages.AddPage();
document.AcroForm.FormFields.AddTextBox("CustomerName");
document.AcroForm.FormFields.AddTextBox("CustomerEmail");
document.AcroForm.FormFields.AddTextBox("ReviewerComment");
Telerik.Documents.Fixed.Model.InteractiveForms.SignatureField signatureField =
document.AcroForm.FormFields.AddSignature("Approval");
signatureField.LockFields(new[] { "CustomerName", "CustomerEmail" });
Alternatively, use signatureField.LockAllFields() or signatureField.LockAllFieldsExcept(new[] { "ReviewerComment" }). To sign during export, assign a Signature and follow the PDF signing workflow.
LockAllFields()also locks other signature fields. For a workflow with later signatures, exclude those signature fields or lock only the fields that must become read-only.
Inspecting and Preserving Lock Settings
Inspect SignatureField.LockSettings through SignatureFieldLock.Action and the read-only Fields list. Change the configuration only through the lock methods.
RadPdfProcessing preserves signature-field lock settings when you import, export, or clone a document. An unsigned field can carry these settings for a later signature in RadPdfProcessing or another PDF application.
When RadPdfProcessing signs the field, it writes a FieldMDP transform, a PDF signature rule that identifies the locked fields. It marks those fields as read-only in the output, not immediately in memory. Full-document export leaves source fields unchanged.
Locks support certificate-based and external signatures with full-document export or PdfStreamSigner.SignDocument. Use PdfStreamSigner.SignExistingField for lock settings already stored in the PDF.
Preserved lock settings do not guarantee that existing signatures remain valid after a full import and export. Use incremental signing to preserve earlier signatures.