iText 7 7.2.5 API
iText.Signatures.PdfSigner Class Reference

Takes care of the cryptographic options and appearances that form a signature. More...

Classes

interface   ISignatureEvent
  An interface to retrieve the signature dictionary for modification. More...
 

Public Types

enum   CryptoStandard { CryptoStandard.CMS, CryptoStandard.CADES }
  Enum containing the Cryptographic Standards. More...
 

Public Member Functions

  PdfSigner (PdfReader reader, Stream outputStream, StampingProperties properties)
  Creates a PdfSigner instance. More...
 
  PdfSigner (PdfReader reader, Stream outputStream, String path, StampingProperties properties)
  Creates a PdfSigner instance. More...
 
virtual DateTime  GetSignDate ()
  Gets the signature date. More...
 
virtual void  SetSignDate (DateTime signDate)
  Sets the signature date. More...
 
virtual PdfSignatureAppearance  GetSignatureAppearance ()
  Provides access to a signature appearance object. More...
 
virtual int  GetCertificationLevel ()
  Returns the document's certification level. More...
 
virtual void  SetCertificationLevel (int certificationLevel)
  Sets the document's certification level. More...
 
virtual String  GetFieldName ()
  Gets the field name. More...
 
virtual PdfSignature  GetSignatureDictionary ()
  Returns the user made signature dictionary. More...
 
virtual PdfSigner.ISignatureEvent  GetSignatureEvent ()
  Getter for property signatureEvent. More...
 
virtual void  SetSignatureEvent (PdfSigner.ISignatureEvent signatureEvent)
  Sets the signature event to allow modification of the signature dictionary. More...
 
virtual String  GetNewSigFieldName ()
  Gets a new signature field name that doesn't clash with any existing name. More...
 
virtual void  SetFieldName (String fieldName)
  Sets the name indicating the field to be signed. More...
 
virtual PdfDocument  GetDocument ()
  Gets the PdfDocument associated with this instance. More...
 
virtual void  SetOriginalOutputStream (Stream originalOS)
  Setter for the OutputStream. More...
 
virtual PdfSigFieldLock  GetFieldLockDict ()
  Getter for the field lock dictionary. More...
 
virtual void  SetFieldLockDict (PdfSigFieldLock fieldLock)
  Setter for the field lock dictionary. More...
 
virtual void  SignDetached (IExternalSignature externalSignature, X509Certificate[] chain, ICollection< ICrlClient > crlList, IOcspClient ocspClient, ITSAClient tsaClient, int estimatedSize, PdfSigner.CryptoStandard sigtype)
  Signs the document using the detached mode, CMS or CAdES equivalent. More...
 
virtual void  SignDetached (IExternalSignature externalSignature, X509Certificate[] chain, ICollection< ICrlClient > crlList, IOcspClient ocspClient, ITSAClient tsaClient, int estimatedSize, PdfSigner.CryptoStandard sigtype, SignaturePolicyInfo signaturePolicy)
  Signs the document using the detached mode, CMS or CAdES equivalent. More...
 
virtual void  SignDetached (IExternalSignature externalSignature, X509Certificate[] chain, ICollection< ICrlClient > crlList, IOcspClient ocspClient, ITSAClient tsaClient, int estimatedSize, PdfSigner.CryptoStandard sigtype, SignaturePolicyIdentifier signaturePolicy)
  Signs the document using the detached mode, CMS or CAdES equivalent. More...
 
virtual void  SignExternalContainer (IExternalSignatureContainer externalSignatureContainer, int estimatedSize)
  Sign the document using an external container, usually a PKCS7. More...
 
virtual void  Timestamp (ITSAClient tsa, String signatureName)
  Signs a document with a PAdES-LTV Timestamp. More...
 

Static Public Member Functions

static void  SignDeferred (PdfDocument document, String fieldName, Stream outs, IExternalSignatureContainer externalSignatureContainer)
  Signs a PDF where space was already reserved. More...
 

Static Public Attributes

const int  NOT_CERTIFIED = 0
  Approval signature. More...
 
const int  CERTIFIED_NO_CHANGES_ALLOWED = 1
  Author signature, no changes allowed. More...
 
const int  CERTIFIED_FORM_FILLING = 2
  Author signature, form filling allowed. More...
 
const int  CERTIFIED_FORM_FILLING_AND_ANNOTATIONS = 3
  Author signature, form filling and annotations allowed. More...
 

Detailed Description

Takes care of the cryptographic options and appearances that form a signature.

Member Enumeration Documentation

◆ CryptoStandard

Enum containing the Cryptographic Standards.

Enum containing the Cryptographic Standards. Possible values are "CMS" and "CADES".

Enumerator
CMS 

Cryptographic Message Syntax.

CADES 

CMS Advanced Electronic Signatures.

Constructor & Destructor Documentation

◆ PdfSigner() [1/2]

iText.Signatures.PdfSigner.PdfSigner ( PdfReader  reader,
Stream  outputStream,
StampingProperties  properties 
)
inline

Creates a PdfSigner instance.

Creates a PdfSigner instance. Uses a System.IO.MemoryStream instead of a temporary file.

Parameters
reader PdfReader that reads the PDF file
outputStream OutputStream to write the signed PDF file
properties

iText.Kernel.Pdf.StampingProperties for the signing document. Note that encryption will be preserved regardless of what is set in properties.

◆ PdfSigner() [2/2]

iText.Signatures.PdfSigner.PdfSigner ( PdfReader  reader,
Stream  outputStream,
String  path,
StampingProperties  properties 
)
inline

Creates a PdfSigner instance.

Creates a PdfSigner instance. Uses a System.IO.MemoryStream instead of a temporary file.

Parameters
reader PdfReader that reads the PDF file
outputStream OutputStream to write the signed PDF file
path File to which the output is temporarily written
properties

iText.Kernel.Pdf.StampingProperties for the signing document. Note that encryption will be preserved regardless of what is set in properties.

Member Function Documentation

◆ GetCertificationLevel()

virtual int iText.Signatures.PdfSigner.GetCertificationLevel ( )
inlinevirtual

Returns the document's certification level.

Returns the document's certification level. For possible values see SetCertificationLevel(int).

Returns
The certified status.

◆ GetDocument()

virtual PdfDocument iText.Signatures.PdfSigner.GetDocument ( )
inlinevirtual

Gets the PdfDocument associated with this instance.

Returns
the PdfDocument associated with this instance

◆ GetFieldLockDict()

virtual PdfSigFieldLock iText.Signatures.PdfSigner.GetFieldLockDict ( )
inlinevirtual

Getter for the field lock dictionary.

Returns
Field lock dictionary.

◆ GetFieldName()

virtual String iText.Signatures.PdfSigner.GetFieldName ( )
inlinevirtual

Gets the field name.

Returns
the field name

◆ GetNewSigFieldName()

virtual String iText.Signatures.PdfSigner.GetNewSigFieldName ( )
inlinevirtual

Gets a new signature field name that doesn't clash with any existing name.

Returns
A new signature field name.

◆ GetSignatureAppearance()

virtual PdfSignatureAppearance iText.Signatures.PdfSigner.GetSignatureAppearance ( )
inlinevirtual

Provides access to a signature appearance object.

Provides access to a signature appearance object. Use it to customize the appearance of the signature.

Be aware:

  • If you create new signature field (either use SetFieldName(System.String) with the name that doesn't exist in the document or don't specify it at all) then the signature is invisible by default.
  • If you sign already existing field, then the signature appearance object is modified to have all the properties (page num., rect etc.) consistent with the state of the field (if you customized the appearance object before the SetFieldName(System.String) call you'll have to do it again)
Returns

PdfSignatureAppearance object.

◆ GetSignatureDictionary()

virtual PdfSignature iText.Signatures.PdfSigner.GetSignatureDictionary ( )
inlinevirtual

Returns the user made signature dictionary.

Returns the user made signature dictionary. This is the dictionary at the /V key of the signature field.

Returns
The user made signature dictionary.

◆ GetSignatureEvent()

virtual PdfSigner.ISignatureEvent iText.Signatures.PdfSigner.GetSignatureEvent ( )
inlinevirtual

Getter for property signatureEvent.

Returns
Value of property signatureEvent.

◆ GetSignDate()

virtual DateTime iText.Signatures.PdfSigner.GetSignDate ( )
inlinevirtual

Gets the signature date.

Returns
Calendar set to the signature date

◆ SetCertificationLevel()

virtual void iText.Signatures.PdfSigner.SetCertificationLevel ( int  certificationLevel )
inlinevirtual

Sets the document's certification level.

Parameters
certificationLevel a new certification level for a document. Possible values are:

◆ SetFieldLockDict()

virtual void iText.Signatures.PdfSigner.SetFieldLockDict ( PdfSigFieldLock  fieldLock )
inlinevirtual

Setter for the field lock dictionary.

Setter for the field lock dictionary.

Be aware: if a signature is created on an existing signature field, then its /Lock dictionary takes the precedence (if it exists).

Parameters
fieldLock Field lock dictionary

◆ SetFieldName()

virtual void iText.Signatures.PdfSigner.SetFieldName ( String  fieldName )
inlinevirtual

Sets the name indicating the field to be signed.

Sets the name indicating the field to be signed. The field can already be presented in the document but shall not be signed. If the field is not presented in the document, it will be created.

Parameters
fieldName The name indicating the field to be signed.

◆ SetOriginalOutputStream()

virtual void iText.Signatures.PdfSigner.SetOriginalOutputStream ( Stream  originalOS )
inlinevirtual

Setter for the OutputStream.

Parameters
originalOS OutputStream for the bytes of the document

◆ SetSignatureEvent()

virtual void iText.Signatures.PdfSigner.SetSignatureEvent ( PdfSigner.ISignatureEvent  signatureEvent )
inlinevirtual

Sets the signature event to allow modification of the signature dictionary.

Parameters
signatureEvent the signature event

◆ SetSignDate()

virtual void iText.Signatures.PdfSigner.SetSignDate ( DateTime  signDate )
inlinevirtual

Sets the signature date.

Parameters
signDate the signature date

◆ SignDeferred()

static void iText.Signatures.PdfSigner.SignDeferred ( PdfDocument  document,
String  fieldName,
Stream  outs,
IExternalSignatureContainer  externalSignatureContainer 
)
inlinestatic

Signs a PDF where space was already reserved.

Parameters
document the original PDF
fieldName the field to sign. It must be the last field
outs the output PDF
externalSignatureContainer the signature container doing the actual signing. Only the method ExternalSignatureContainer.sign is used

◆ SignDetached() [1/3]

virtual void iText.Signatures.PdfSigner.SignDetached ( IExternalSignature  externalSignature,
X509Certificate[]  chain,
ICollection< ICrlClient crlList,
IOcspClient  ocspClient,
ITSAClient  tsaClient,
int  estimatedSize,
PdfSigner.CryptoStandard  sigtype 
)
inlinevirtual

Signs the document using the detached mode, CMS or CAdES equivalent.

Signs the document using the detached mode, CMS or CAdES equivalent.

NOTE: This method closes the underlying pdf document. This means, that current instance of PdfSigner cannot be used after this method call.

Parameters
externalSignature the interface providing the actual signing
chain the certificate chain
crlList the CRL list
ocspClient the OCSP client
tsaClient the Timestamp client
estimatedSize the reserved size for the signature. It will be estimated if 0
sigtype Either Signature.CMS or Signature.CADES

◆ SignDetached() [2/3]

virtual void iText.Signatures.PdfSigner.SignDetached ( IExternalSignature  externalSignature,
X509Certificate[]  chain,
ICollection< ICrlClient crlList,
IOcspClient  ocspClient,
ITSAClient  tsaClient,
int  estimatedSize,
PdfSigner.CryptoStandard  sigtype,
SignaturePolicyIdentifier  signaturePolicy 
)
inlinevirtual

Signs the document using the detached mode, CMS or CAdES equivalent.

Signs the document using the detached mode, CMS or CAdES equivalent.

NOTE: This method closes the underlying pdf document. This means, that current instance of PdfSigner cannot be used after this method call.

Parameters
externalSignature the interface providing the actual signing
chain the certificate chain
crlList the CRL list
ocspClient the OCSP client
tsaClient the Timestamp client
estimatedSize the reserved size for the signature. It will be estimated if 0
sigtype Either Signature.CMS or Signature.CADES
signaturePolicy the signature policy (for EPES signatures)

◆ SignDetached() [3/3]

virtual void iText.Signatures.PdfSigner.SignDetached ( IExternalSignature  externalSignature,
X509Certificate[]  chain,
ICollection< ICrlClient crlList,
IOcspClient  ocspClient,
ITSAClient  tsaClient,
int  estimatedSize,
PdfSigner.CryptoStandard  sigtype,
SignaturePolicyInfo  signaturePolicy 
)
inlinevirtual

Signs the document using the detached mode, CMS or CAdES equivalent.

Signs the document using the detached mode, CMS or CAdES equivalent.

NOTE: This method closes the underlying pdf document. This means, that current instance of PdfSigner cannot be used after this method call.

Parameters
externalSignature the interface providing the actual signing
chain the certificate chain
crlList the CRL list
ocspClient the OCSP client
tsaClient the Timestamp client
estimatedSize the reserved size for the signature. It will be estimated if 0
sigtype Either Signature.CMS or Signature.CADES
signaturePolicy the signature policy (for EPES signatures)

◆ SignExternalContainer()

virtual void iText.Signatures.PdfSigner.SignExternalContainer ( IExternalSignatureContainer  externalSignatureContainer,
int  estimatedSize 
)
inlinevirtual

Sign the document using an external container, usually a PKCS7.

Sign the document using an external container, usually a PKCS7. The signature is fully composed externally, iText will just put the container inside the document.

NOTE: This method closes the underlying pdf document. This means, that current instance of PdfSigner cannot be used after this method call.

Parameters
externalSignatureContainer the interface providing the actual signing
estimatedSize the reserved size for the signature

◆ Timestamp()

virtual void iText.Signatures.PdfSigner.Timestamp ( ITSAClient  tsa,
String  signatureName 
)
inlinevirtual

Signs a document with a PAdES-LTV Timestamp.

Signs a document with a PAdES-LTV Timestamp. The document is closed at the end.

NOTE: This method closes the underlying pdf document. This means, that current instance of PdfSigner cannot be used after this method call.

Parameters
tsa the timestamp generator
signatureName the signature name or null to have a name generated automatically

Member Data Documentation

◆ CERTIFIED_FORM_FILLING

const int iText.Signatures.PdfSigner.CERTIFIED_FORM_FILLING = 2
static

Author signature, form filling allowed.

◆ CERTIFIED_FORM_FILLING_AND_ANNOTATIONS

const int iText.Signatures.PdfSigner.CERTIFIED_FORM_FILLING_AND_ANNOTATIONS = 3
static

Author signature, form filling and annotations allowed.

◆ CERTIFIED_NO_CHANGES_ALLOWED

const int iText.Signatures.PdfSigner.CERTIFIED_NO_CHANGES_ALLOWED = 1
static

Author signature, no changes allowed.

◆ NOT_CERTIFIED

const int iText.Signatures.PdfSigner.NOT_CERTIFIED = 0
static

Approval signature.