Table of Contents

Class BatchSigner

Namespace
SimpleSign.PAdES.Signing
Assembly
SimpleSign.PAdES.dll

High-performance batch signer that reuses certificate, HTTP connections, and TSA sessions to sign multiple PDFs efficiently.

public sealed class BatchSigner : IAsyncDisposable
Inheritance
BatchSigner
Implements
Inherited Members

Properties

AverageElapsedMs

Average signing time per document in milliseconds.

public double AverageElapsedMs { get; }

Property Value

double

FailureCount

Number of PDFs that failed to sign.

public int FailureCount { get; }

Property Value

int

SuccessCount

Number of PDFs successfully signed.

public int SuccessCount { get; }

Property Value

int

Methods

Create(X509Certificate2)

Creates a new BatchSigner.BatchSignerBuilder for configuring the batch signer.

public static BatchSigner.BatchSignerBuilder Create(X509Certificate2 certificate)

Parameters

certificate X509Certificate2

Returns

BatchSigner.BatchSignerBuilder

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

ResetMetrics()

Resets the success/failure counters and average elapsed time.

public void ResetMetrics()

SignAllAsync(IAsyncEnumerable<(string Id, byte[] PdfBytes)>, CancellationToken)

Signs all PDFs from an async enumerable, yielding results as they complete. Respects SimpleSign.PAdES.Signing.BatchSigner.BatchSignerBuilder.MaxConcurrency for parallel execution.

public IAsyncEnumerable<BatchSignResult> SignAllAsync(IAsyncEnumerable<(string Id, byte[] PdfBytes)> inputs, CancellationToken cancellationToken = default)

Parameters

inputs IAsyncEnumerable<(string Id, byte[] PdfBytes)>

Async enumerable of (identifier, PDF bytes) pairs.

cancellationToken CancellationToken

Cancellation token.

Returns

IAsyncEnumerable<BatchSignResult>

Async enumerable of batch results.

SignAsync(byte[], CancellationToken)

Signs a single PDF and returns the signed bytes.

public Task<byte[]> SignAsync(byte[] pdfBytes, CancellationToken cancellationToken = default)

Parameters

pdfBytes byte[]

Input PDF bytes.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<byte[]>

Signed PDF bytes.

SignAsync(Stream, Stream, CancellationToken)

Signs a single PDF using the pre-configured certificate and options.

public Task SignAsync(Stream pdfStream, Stream outputStream, CancellationToken cancellationToken = default)

Parameters

pdfStream Stream

Seekable input PDF stream.

outputStream Stream

Output stream for the signed PDF.

cancellationToken CancellationToken

Cancellation token.

Returns

Task