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
PdfReaderPdfReader instance to read the original PDF file
outputStream
StreamStream 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
PdfDocumentthe original PDF
fieldName
stringthe field to sign. It must be the last field
outs
Streamthe 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
PdfDocumentthe original PDF
fieldName
stringthe field to sign. It must be the last field
outs
Streamthe output PDF
cmsContainer
CMSContainerthe 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
SignerPropertiesSignerProperties properties to be used for main signing operation
digestAlgorithm
stringthe algorithm to generate the digest with
filter
PdfNamePdfName of the signature handler to use when validating this signature
subFilter
PdfNamePdfName that describes the encoding of the signature
estimatedSize
intthe estimated size of the signature, this is the size of the space reserved for the Cryptographic Message Container
includeDate
boolspecifies 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
IExternalDigestthe 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
StampingPropertiesStampingProperties 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