---
title: "Signature"
canonical_url: "https://www.nutrient.io/api/csharp/signing/signature/"
md_url: "https://www.nutrient.io/api/csharp/signing/signature.md"
last_updated: "2026-10-08T08:55:57.713Z"
description: "Provides functionality for signing PDF documents. Supports both digital signatures (with certificate) and electronic signatures (visual only)."
---

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.

```csharp

using Nutrient;

```

## Construction

```csharp

public Signature()

```

## Methods

### AddDocumentTimestamp

```csharp

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

| Name         | Type                                                                     | Description                                   |
| ------------ | ------------------------------------------------------------------------ | --------------------------------------------- |
| `document`   | [`Document`](/api/csharp/document/)                                      | The document to timestamp.                    |
| `outputPath` | `string`                                                                 | The path where the updated PDF will be saved. |
| `timestamp`  | [`TimestampConfiguration`](/api/csharp/signing/timestamp-configuration/) | The timestamp authority configuration.        |

```csharp

public void AddDocumentTimestamp(Document document, Stream output, TimestampConfiguration timestamp)

```

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

**Parameters**

| Name        | Type                                                                     | Description                                              |
| ----------- | ------------------------------------------------------------------------ | -------------------------------------------------------- |
| `document`  | [`Document`](/api/csharp/document/)                                      | The document to timestamp.                               |
| `output`    | `Stream`                                                                 | The output stream where the updated PDF will be written. |
| `timestamp` | [`TimestampConfiguration`](/api/csharp/signing/timestamp-configuration/) | The timestamp authority configuration.                   |

### AddLtvInformation

```csharp

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

| Name         | Type                                | Description                                        |
| ------------ | ----------------------------------- | -------------------------------------------------- |
| `document`   | [`Document`](/api/csharp/document/) | The signed document to add validation material to. |
| `outputPath` | `string`                            | The path where the updated PDF will be saved.      |

```csharp

public void AddLtvInformation(Document document, Stream output)

```

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

**Parameters**

| Name       | Type                                | Description                                              |
| ---------- | ----------------------------------- | -------------------------------------------------------- |
| `document` | [`Document`](/api/csharp/document/) | The signed document to add validation material to.       |
| `output`   | `Stream`                            | The output stream where the updated PDF will be written. |

### FinishSignature

```csharp

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

| Name               | Type                                                                        | Description                                                              |
| ------------------ | --------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| `preparedDocument` | [`Document`](/api/csharp/document/)                                         | The prepared document returned by `PrepareSignature`.                    |
| `outputPath`       | `string`                                                                    | The path where the signed PDF will be saved.                             |
| `signedData`       | `Byte[]`                                                                    | The raw signature value over the prepared bytes.                         |
| `options`          | [`DigitalSignatureOptions`](/api/csharp/signing/digital-signature-options/) | The digital signature options with the same certificate used to prepare. |

```csharp

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

| Name               | Type                                                                        | Description                                                              |
| ------------------ | --------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| `preparedDocument` | [`Document`](/api/csharp/document/)                                         | The prepared document.                                                   |
| `output`           | `Stream`                                                                    | The output stream where the signed PDF will be written.                  |
| `signedData`       | `Byte[]`                                                                    | The raw signature value over the prepared bytes.                         |
| `options`          | [`DigitalSignatureOptions`](/api/csharp/signing/digital-signature-options/) | The digital signature options with the same certificate used to prepare. |

### FinishSignatureWithCms

```csharp

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

| Name                 | Type                                | Description                                        |
| -------------------- | ----------------------------------- | -------------------------------------------------- |
| `preparedDocument`   | [`Document`](/api/csharp/document/) | The prepared document.                             |
| `outputPath`         | `string`                            | The path where the signed PDF will be saved.       |
| `signatureContainer` | `Byte[]`                            | The complete, DER-encoded CMS signature container. |

```csharp

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

| Name                 | Type                                | Description                                             |
| -------------------- | ----------------------------------- | ------------------------------------------------------- |
| `preparedDocument`   | [`Document`](/api/csharp/document/) | The prepared document.                                  |
| `output`             | `Stream`                            | The output stream where the signed PDF will be written. |
| `signatureContainer` | `Byte[]`                            | The complete, DER-encoded CMS signature container.      |

### PrepareSignature

```csharp

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

| Name         | Type                                                                        | Description                                                       |
| ------------ | --------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| `document`   | [`Document`](/api/csharp/document/)                                         | The document to prepare for signing.                              |
| `outputPath` | `string`                                                                    | The path where the prepared PDF will be saved.                    |
| `options`    | [`DigitalSignatureOptions`](/api/csharp/signing/digital-signature-options/) | The digital signature options, including the signing certificate. |

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

```csharp

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

| Name       | Type                                                                        | Description                                                       |
| ---------- | --------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| `document` | [`Document`](/api/csharp/document/)                                         | The document to prepare for signing.                              |
| `output`   | `Stream`                                                                    | The output stream where the prepared PDF will be written.         |
| `options`  | [`DigitalSignatureOptions`](/api/csharp/signing/digital-signature-options/) | The digital signature options, including the signing certificate. |

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

### Sign

```csharp

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

```

Applies an invisible digital signature to a document.

**Parameters**

| Name         | Type                                                                        | Description                                                       |
| ------------ | --------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| `document`   | [`Document`](/api/csharp/document/)                                         | The document to sign.                                             |
| `outputPath` | `string`                                                                    | The path where the signed PDF will be saved.                      |
| `options`    | [`DigitalSignatureOptions`](/api/csharp/signing/digital-signature-options/) | The digital signature options including certificate and metadata. |

```csharp

public void Sign(Document document, Stream output, DigitalSignatureOptions options)

```

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

**Parameters**

| Name       | Type                                                                        | Description                                                       |
| ---------- | --------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| `document` | [`Document`](/api/csharp/document/)                                         | The document to sign.                                             |
| `output`   | `Stream`                                                                    | The output stream where the signed PDF will be written.           |
| `options`  | [`DigitalSignatureOptions`](/api/csharp/signing/digital-signature-options/) | The digital signature options including certificate and metadata. |

### SignField

```csharp

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

| Name         | Type                                                                        | Description                                                             |
| ------------ | --------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| `document`   | [`Document`](/api/csharp/document/)                                         | The document to sign.                                                   |
| `outputPath` | `string`                                                                    | The path where the signed PDF will be saved.                            |
| `fieldName`  | `string`                                                                    | The name of the existing signature form field to use for the signature. |
| `options`    | [`DigitalSignatureOptions`](/api/csharp/signing/digital-signature-options/) | The digital signature options. Can be null for electronic signatures.   |
| `appearance` | [`SignatureAppearance`](/api/csharp/signing/signature-appearance/)          | The visual appearance of the signature.                                 |

```csharp

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

| Name         | Type                                                                        | Description                                                             |
| ------------ | --------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| `document`   | [`Document`](/api/csharp/document/)                                         | The document to sign.                                                   |
| `output`     | `Stream`                                                                    | The output stream where the signed PDF will be written.                 |
| `fieldName`  | `string`                                                                    | The name of the existing signature form field to use for the signature. |
| `options`    | [`DigitalSignatureOptions`](/api/csharp/signing/digital-signature-options/) | The digital signature options. Can be null for electronic signatures.   |
| `appearance` | [`SignatureAppearance`](/api/csharp/signing/signature-appearance/)          | The visual appearance of the signature.                                 |

## Resource management

```csharp

public void Dispose()

```

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

---

## Related pages

- [Signing](/api/csharp/signing.md)
- [Digital Signature Options](/api/csharp/signing/digital-signature-options.md)
- [Pkcs11 Options](/api/csharp/signing/pkcs11-options.md)
- [Signature Appearance](/api/csharp/signing/signature-appearance.md)
- [Timestamp Configuration](/api/csharp/signing/timestamp-configuration.md)

