Table of Contents

Class PdfTwoPhaseSigner

Namespace
iText.Signatures
Assembly
itext.sign.dll

Class that prepares document and adds the signature to it while performing signing operation in two steps (see PadesTwoPhaseSigningHelper for more info).

public class PdfTwoPhaseSigner
Inheritance
PdfTwoPhaseSigner
Inherited Members

Remarks

Class that prepares document and adds the signature to it while performing signing operation in two steps (see PadesTwoPhaseSigningHelper for more info).

Firstly, this class allows to prepare the document for signing and calculate the document digest to sign. Secondly, it adds an existing signature to a PDF where space was already reserved.

Constructors

PdfTwoPhaseSigner(PdfReader, Stream)

Creates new PdfTwoPhaseSigner instance.

public PdfTwoPhaseSigner(PdfReader reader, Stream outputStream)

Parameters

reader PdfReader

PdfReader instance to read the original PDF file

outputStream Stream

Stream output stream to write the resulting PDF file into

Methods

AddSignatureToPreparedDocument(PdfDocument, string, Stream, byte[])

Adds an existing signature to a PDF where space was already reserved.

public static void AddSignatureToPreparedDocument(PdfDocument document, string fieldName, Stream outs, byte[] signedContent)

Parameters

document PdfDocument

the original PDF

fieldName string

the field to sign. It must be the last field

outs Stream

the output PDF

signedContent byte[]

the bytes for the signed data

AddSignatureToPreparedDocument(PdfDocument, string, Stream, CMSContainer)

Adds an existing signature to a PDF where space was already reserved.

public static void AddSignatureToPreparedDocument(PdfDocument document, string fieldName, Stream outs, CMSContainer cmsContainer)

Parameters

document PdfDocument

the original PDF

fieldName string

the field to sign. It must be the last field

outs Stream

the output PDF

cmsContainer CMSContainer

the finalized CMS container

PrepareDocumentForSignature(SignerProperties, string, PdfName, PdfName, int, bool)

Prepares document for signing, calculates the document digest to sign and closes the document.

public virtual byte[] PrepareDocumentForSignature(SignerProperties signerProperties, string digestAlgorithm, PdfName filter, PdfName subFilter, int estimatedSize, bool includeDate)

Parameters

signerProperties SignerProperties

SignerProperties properties to be used for main signing operation

digestAlgorithm string

the algorithm to generate the digest with

filter PdfName

PdfName of the signature handler to use when validating this signature

subFilter PdfName

PdfName that describes the encoding of the signature

estimatedSize int

the estimated size of the signature, this is the size of the space reserved for the Cryptographic Message Container

includeDate bool

specifies if the signing date should be set to the signature dictionary

Returns

byte[]

the message digest of the prepared document.

SetExternalDigest(IExternalDigest)

Use the external digest to inject specific digest implementations

public virtual PdfTwoPhaseSigner SetExternalDigest(IExternalDigest externalDigest)

Parameters

externalDigest IExternalDigest

the IExternalDigest instance to use to generate Digests

Returns

PdfTwoPhaseSigner

same instance of PdfTwoPhaseSigner

SetStampingProperties(StampingProperties)

Set stamping properties to be used during main signing operation.

public virtual PdfTwoPhaseSigner SetStampingProperties(StampingProperties stampingProperties)

Parameters

stampingProperties StampingProperties

StampingProperties instance to be used during main signing operation

Returns

PdfTwoPhaseSigner

same instance of PdfTwoPhaseSigner

Remarks

Set stamping properties to be used during main signing operation.

If none is set, stamping properties with append mode enabled will be used