Class PdfSignature
A class that represents a PDF signing certificate (.PFX or .p12) format which can be used to digitally sign a PDF. This protecting it from alteration, Also PKCS11 converted to 12.
Inheritance
Namespace: IronPdf.Signing
Assembly: IronPdf.dll
Syntax
public class PdfSignature : Object
PdfSignature is the object IronPDF C# code works with for PDF signing. It represents that represents a PDF signing certificate (.PFX or .p12) format which can be used to digitally sign a PDF.
PdfSignature matters when an application needs to configure or invoke PDF signing from C# code. The class encapsulates the related options and behavior in a single object that is set up once and reused across render or processing calls. Typical scenarios include batch generation pipelines, templated document workflows, and integration with existing C# document services.
To use PdfSignature, instantiate or obtain it from the relevant entry point in the IronPDF C# API. Key methods include FromBase64, LoadSignatureImageFromFile, LoadSignatureImageFromStream. Assign options or invoke methods on the instance to configure or perform the operation. The signing covers typical usage in C# end to end.
using IronPdf;
// Obtain PdfSignature from the relevant entry point in the IronPDF API
void Configure(PdfSignature instance)
{
instance.FromBase64();
}For the broader workflow, see the signing PDF with hsm guide in the IronPDF C# documentation. For broader context, the PDF signing portion of the IronPDF C# API contains related types that work with PdfSignature directly. PdfSignature exposes additional members beyond those highlighted above; the reference tables on this page list the full set. In application code, treat PdfSignature as a configured object that is constructed once and reused across operations rather than instantiated per call. Configuration is generally idempotent: assigning the same property value twice has the same effect as assigning it once. For diagnostic purposes, inspect the relevant PdfSignature property after each operation to confirm the configured state. See the constructors, properties, and methods tables below for the complete API surface of PdfSignature.
Constructors
PdfSignature(Byte[], String, String)
Initializes a new instance of the PdfSignature class.
Declaration
public PdfSignature(byte[] CertificateRawData, string Password, string TimeStampUrl = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | CertificateRawData | The certificate as a binary data (byte array). |
| System.String | Password | The certificate's password. |
| System.String | TimeStampUrl | Url used for time-stamping the signature. |
PdfSignature(X509Certificate2)
Initializes a new instance of the PdfSignature class. Not working in docker mode (Installation.UseIronPdfEngineDocker)
Declaration
public PdfSignature(X509Certificate2 exportableNativeCertificate)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Security.Cryptography.X509Certificates.X509Certificate2 | exportableNativeCertificate | The exportable native certificate as a System.Security.Cryptography.X509Certificates.X509Certificate2. |
PdfSignature(String, String, String)
Initializes a new instance of the PdfSignature class using a .pfx or .p12 digital signature file.
Declaration
public PdfSignature(string FilePathToCertificate, string Password, string TimeStampUrl = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | FilePathToCertificate | The file path to certificate. |
| System.String | Password | The certificate's password. |
| System.String | TimeStampUrl | Url used for time-stamping the signature. |
Fields
ContactInformation
The contact phone number or email address for signing related inquiries (optional).
Declaration
public string ContactInformation
Field Value
| Type | Description |
|---|---|
| System.String |
SignatureDate
The date and time of the digital signature. If left null, the signature will be timestamped at the millisecond that the PdfDocument is saved to Disk or Stream.
The value is converted to UTC for the signature timestamp. A value whose
System.DateTime.Kind is Local or Unspecified is interpreted as local time and
shifted by the machine's UTC offset. Supply a Utc-kind value to record the instant unchanged.
Declaration
public Nullable<DateTime> SignatureDate
Field Value
| Type | Description |
|---|---|
| System.Nullable<System.DateTime> |
SignatureFieldName
The name of an existing, unsigned signature form field to sign into. When set, signing fills that pre-existing field where the form author placed it, instead of creating a new signature field.
Use the field names reported by PdfDocument.GetForm() (a
SignatureFormField.Name). Signing throws if no unsigned field with that name exists,
or if the named field is already signed.
Leave null, empty, or whitespace to keep the default behavior of appending a new
signature field.
Cannot be combined with SignatureImage: applying a signature image rewrites the field's rectangle and page, which would move the pre-placed block. Doing so throws.
The SignaturePermissions passed to signing are not applied on this path: filling a
pre-placed field always produces an ordinary approval signature, with no DocMDP certification or
document lock, even for a certification-level permission such as NoChangesAllowed. A
document that ships an empty, unsigned field is not yet certified, so a fill never certifies it.
Only one signature may be applied per open document, and this applies to plain appends
too, not only the named-field path. Adding a second signature to the same open document throws
NotSupportedException whether or not it was saved in between, because each signature
covers the other's contents and only the last would verify. To sign several fields, sign one,
save, reopen the saved bytes, then sign the next.
Declaration
public string SignatureFieldName
Field Value
| Type | Description |
|---|---|
| System.String |
SignatureImage
A visual image for the sign, often a PNG of a human signature or company stamp (optional).
This appends a visual signature in addition to cryptographic signing.
LoadSignatureImageFromFile(String, Int32, Rectangle)LoadSignatureImageFromStream(Stream, Int32, Rectangle)Declaration
public PdfSignatureImage SignatureImage
Field Value
| Type | Description |
|---|---|
| PdfSignatureImage |
SigningContact
The contact person (optional).
Declaration
public string SigningContact
Field Value
| Type | Description |
|---|---|
| System.String |
SigningLocation
The physical location the PDF was signed (optional).
Declaration
public string SigningLocation
Field Value
| Type | Description |
|---|---|
| System.String |
SigningReason
The reason the PDF was signed (optional).
Declaration
public string SigningReason
Field Value
| Type | Description |
|---|---|
| System.String |
TimeStampUrl
Url to be used when time-stamping the signature
Declaration
public string TimeStampUrl
Field Value
| Type | Description |
|---|---|
| System.String |
Properties
SignatureHashAlgorithm
The hashing algorithm used to compute the PKCS#7/CMS signature digest. Defaults to SHA256.
Declaration
public SignatureHashAlgorithms SignatureHashAlgorithm { get; set; }
Property Value
| Type | Description |
|---|---|
| SignatureHashAlgorithms |
TimestampHashAlgorithm
Algorithm requested to be used by the time-stamping server for the RFC 3161 message imprint. Defaults to SHA256.
Declaration
public TimestampHashAlgorithms TimestampHashAlgorithm { get; set; }
Property Value
| Type | Description |
|---|---|
| TimestampHashAlgorithms |
Methods
FromBase64(String, String, String)
Create a new PDF signature from the specified base64 string
Declaration
public static PdfSignature FromBase64(string Base64, string Password = null, string TimeStampUrl = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | Base64 | Base-64 string which represents a certificate |
| System.String | Password | Certificate password |
| System.String | TimeStampUrl | Optional Time-stamping URL |
Returns
| Type | Description |
|---|---|
| PdfSignature | PDF signature |
LoadSignatureImageFromFile(String, Int32, Rectangle)
Loads a signature image from an image file. This appends a visual signature in addition to cryptographic signing.
Declaration
public void LoadSignatureImageFromFile(string FilePath, int PageIndex, Rectangle Rectangle)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | FilePath | Image path |
| System.Int32 | PageIndex | Page index to display image |
| IronSoftware.Drawing.Rectangle | Rectangle | Rectangle to display image |
LoadSignatureImageFromStream(Stream, Int32, Rectangle)
Loads a signature image from a stream. This appends visual signature in addition to cryptographic signing.
Declaration
public void LoadSignatureImageFromStream(Stream Stream, int PageIndex, Rectangle Rectangle)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IO.Stream | Stream | The image file as a stream. |
| System.Int32 | PageIndex | Page index to display image |
| IronSoftware.Drawing.Rectangle | Rectangle | Rectangle to display image |