This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /api/csharp/signing/signature.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Signature

Provides functionality for signing PDF documents. Supports both digital signatures (with certificate) and electronic signatures (visual only).

The Signature class enables adding signatures to PDF documents: Digital signatures use PFX/P12 certificates to cryptographically sign the document.Electronic signatures add visual representation (image/text) without cryptographic signing. For PAdES-B compliance, use CAdES signature mode (the default). For PAdES-T compliance, configure a TimestampConfiguration in the signature options.

using Nutrient;

Construction

public Signature()

Methods

AddDocumentTimestamp

public void AddDocumentTimestamp(Document document, string outputPath, TimestampConfiguration timestamp)

Appends a document timestamp to a document, protecting its current state and its validation material.

Parameters

NameTypeDescription
documentDocumentThe document to timestamp.
outputPathstringThe path where the updated PDF will be saved.
timestampTimestampConfigurationThe timestamp authority configuration.
public void AddDocumentTimestamp(Document document, Stream output, TimestampConfiguration timestamp)

Appends a document timestamp to a document, writing the result to a stream.

Parameters

NameTypeDescription
documentDocumentThe document to timestamp.
outputStreamThe output stream where the updated PDF will be written.
timestampTimestampConfigurationThe timestamp authority configuration.

AddLtvInformation

public void AddLtvInformation(Document document, string outputPath)

Adds long-term validation material — certificates and revocation information — for all signed signatures of a document, upgrading it toward PAdES B-LT.

Parameters

NameTypeDescription
documentDocumentThe signed document to add validation material to.
outputPathstringThe path where the updated PDF will be saved.
public void AddLtvInformation(Document document, Stream output)

Adds long-term validation material for all signed signatures, writing the result to a stream.

Parameters

NameTypeDescription
documentDocumentThe signed document to add validation material to.
outputStreamThe output stream where the updated PDF will be written.

FinishSignature

public void FinishSignature(Document preparedDocument, string outputPath, Byte[] signedData, DigitalSignatureOptions options)

Completes external signing (phase two) with a raw signature value produced by an external signer.

Parameters

NameTypeDescription
preparedDocumentDocumentThe prepared document returned by PrepareSignature.
outputPathstringThe path where the signed PDF will be saved.
signedDataByte[]The raw signature value over the prepared bytes.
optionsDigitalSignatureOptionsThe digital signature options with the same certificate used to prepare.
public void FinishSignature(Document preparedDocument, Stream output, Byte[] signedData, DigitalSignatureOptions options)

Completes external signing (phase two) with a raw signature value, writing the result to a stream.

Parameters

NameTypeDescription
preparedDocumentDocumentThe prepared document.
outputStreamThe output stream where the signed PDF will be written.
signedDataByte[]The raw signature value over the prepared bytes.
optionsDigitalSignatureOptionsThe digital signature options with the same certificate used to prepare.

FinishSignatureWithCms

public void FinishSignatureWithCms(Document preparedDocument, string outputPath, Byte[] signatureContainer)

Completes external signing (phase two) with a complete signature container produced by an external signing service.

Parameters

NameTypeDescription
preparedDocumentDocumentThe prepared document.
outputPathstringThe path where the signed PDF will be saved.
signatureContainerByte[]The complete, DER-encoded CMS signature container.
public void FinishSignatureWithCms(Document preparedDocument, Stream output, Byte[] signatureContainer)

Completes external signing (phase two) with a complete signature container, writing the result to a stream.

Parameters

NameTypeDescription
preparedDocumentDocumentThe prepared document.
outputStreamThe output stream where the signed PDF will be written.
signatureContainerByte[]The complete, DER-encoded CMS signature container.

PrepareSignature

public Byte[] PrepareSignature(Document document, string outputPath, DigitalSignatureOptions options)

Starts external signing (phase one): prepares the document with a signature placeholder and returns the exact bytes an external signer must sign.

Parameters

NameTypeDescription
documentDocumentThe document to prepare for signing.
outputPathstringThe path where the prepared PDF will be saved.
optionsDigitalSignatureOptionsThe digital signature options, including the signing certificate.

Returns: Byte[] - The bytes to be signed by the external signer.

public Byte[] PrepareSignature(Document document, Stream output, DigitalSignatureOptions options)

Starts external signing (phase one), writing the prepared PDF to a stream and returning the bytes an external signer must sign.

Parameters

NameTypeDescription
documentDocumentThe document to prepare for signing.
outputStreamThe output stream where the prepared PDF will be written.
optionsDigitalSignatureOptionsThe digital signature options, including the signing certificate.

Returns: Byte[] - The bytes to be signed by the external signer.

Sign

public void Sign(Document document, string outputPath, DigitalSignatureOptions options)

Applies an invisible digital signature to a document.

Parameters

NameTypeDescription
documentDocumentThe document to sign.
outputPathstringThe path where the signed PDF will be saved.
optionsDigitalSignatureOptionsThe digital signature options including certificate and metadata.
public void Sign(Document document, Stream output, DigitalSignatureOptions options)

Applies an invisible digital signature to a document, writing the result to a stream.

Parameters

NameTypeDescription
documentDocumentThe document to sign.
outputStreamThe output stream where the signed PDF will be written.
optionsDigitalSignatureOptionsThe digital signature options including certificate and metadata.

SignField

public void SignField(Document document, string outputPath, string fieldName, DigitalSignatureOptions? options, SignatureAppearance? appearance)

Applies a signature to a document using an existing signature field. Supports both digital signatures (with certificate) and electronic signatures (visual only).

Parameters

NameTypeDescription
documentDocumentThe document to sign.
outputPathstringThe path where the signed PDF will be saved.
fieldNamestringThe name of the existing signature form field to use for the signature.
optionsDigitalSignatureOptionsThe digital signature options. Can be null for electronic signatures.
appearanceSignatureAppearanceThe visual appearance of the signature.
public void SignField(Document document, Stream output, string fieldName, DigitalSignatureOptions? options, SignatureAppearance? appearance)

Applies a signature to a document using an existing signature field, writing the result to a stream. Supports both digital signatures (with certificate) and electronic signatures (visual only).

Parameters

NameTypeDescription
documentDocumentThe document to sign.
outputStreamThe output stream where the signed PDF will be written.
fieldNamestringThe name of the existing signature form field to use for the signature.
optionsDigitalSignatureOptionsThe digital signature options. Can be null for electronic signatures.
appearanceSignatureAppearanceThe visual appearance of the signature.

Resource management

public void Dispose()

Signature implements IDisposable and owns native resources. Always call Dispose() or use a C# using declaration: it is not released automatically.