iText 9.0.0 API
|
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 stampingProperties, SignerProperties signerProperties) | |
Creates a PdfSigner instance. More... |
|
PdfSigner (PdfReader reader, Stream outputStream, String path, StampingProperties properties) | |
Creates a PdfSigner instance. More... |
|
virtual PdfSigner | SetSignerProperties (SignerProperties properties) |
Sets the properties to be used in signing operations. More... |
|
virtual SignerProperties | GetSignerProperties () |
Gets the properties to be used in signing operations. 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 PdfDocument | GetDocument () |
Gets the PdfDocument associated with this instance. More... |
|
virtual void | SetOriginalOutputStream (Stream originalOS) |
Setter for the OutputStream. More... |
|
virtual PdfSignatureFormField | GetSignatureField () |
Gets the signature field to be signed. More... |
|
virtual void | SignDetached (IExternalDigest externalDigest, IExternalSignature externalSignature, IX509Certificate[] 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, IX509Certificate[] 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 (IExternalDigest externalDigest, IExternalSignature externalSignature, IX509Certificate[] 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, IX509Certificate[] 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, IX509Certificate[] chain, ICollection< ICrlClient > crlList, IOcspClient ocspClient, ITSAClient tsaClient, int estimatedSize, PdfSigner.CryptoStandard sigtype, ISignaturePolicyIdentifier signaturePolicy) |
Signs the document using the detached mode, CMS or CAdES equivalent. More... |
|
virtual void | SignDetached (IExternalDigest externalDigest, IExternalSignature externalSignature, IX509Certificate[] chain, ICollection< ICrlClient > crlList, IOcspClient ocspClient, ITSAClient tsaClient, int estimatedSize, PdfSigner.CryptoStandard sigtype, ISignaturePolicyIdentifier 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... |
|
Package Functions |
|
virtual PdfDocument | InitDocument (PdfReader reader, PdfWriter writer, StampingProperties properties) |
Initialize new iText.Kernel.Pdf.PdfDocument instance by using provided parameters. More... |
|
virtual void | SetDocument (PdfDocument document) |
Sets the PdfDocument. More... |
|
virtual ICollection< byte[]> | ProcessCrl (IX509Certificate cert, ICollection< ICrlClient > crlList) |
Processes a CRL list. More... |
|
virtual void | AddDeveloperExtension (PdfDeveloperExtension extension) |
Add developer extension to the current iText.Kernel.Pdf.PdfDocument. More... |
|
virtual bool | IsPreClosed () |
Checks if the document is in the process of closing. More... |
|
virtual void | PreClose (IDictionary< PdfName, int?> exclusionSizes) |
This is the first method to be called when using external signatures. More... |
|
virtual SignatureFieldAppearance | GetSignatureAppearance () |
Returns final signature appearance object set by SignerProperties.SetSignatureAppearance(iText.Forms.Form.Element.SignatureFieldAppearance) and customized using PdfSigner properties such as signing date, reason, location and signer name in case they weren't specified by the user, or, if none was set, returns a new one with default appearance. More... |
|
virtual PdfSigFieldLock | PopulateExistingSignatureFormField (PdfAcroForm acroForm) |
Populates already existing signature form field in the acroForm object. More... |
|
virtual PdfSigFieldLock | CreateNewSignatureFormField (PdfAcroForm acroForm, String name) |
Creates new signature form field and adds it to the acroForm object. More... |
|
virtual Stream | GetRangeStream () |
Gets the document bytes that are hashable when using external signatures. More... |
|
virtual void | Close (PdfDictionary update) |
This is the last method to be called when using external signatures. More... |
|
virtual IRandomAccessSource | GetUnderlyingSource () |
Returns the underlying source. More... |
|
virtual void | AddDocMDP (PdfSignature crypto) |
Adds keys to the signature dictionary that define the certification level and the permissions. More... |
|
virtual void | AddFieldMDP (PdfSignature crypto, PdfSigFieldLock fieldLock) |
Adds keys to the signature dictionary that define the field permissions. More... |
|
virtual bool | DocumentContainsCertificationOrApprovalSignatures () |
Check if current document instance already contains certification or approval signatures. More... |
|
virtual Rectangle | GetWidgetRectangle (PdfWidgetAnnotation widget) |
Get the rectangle associated to the provided widget. More... |
|
virtual int | GetWidgetPageNumber (PdfWidgetAnnotation widget) |
Get the page number associated to the provided widget. More... |
|
virtual void | ApplyAccessibilityProperties (PdfFormField formField, IAccessibleElement modelElement, PdfDocument pdfDocument) |
delegate byte[] | ISignatureDataProvider (PdfSigner.SignatureApplier applier) |
Package Attributes |
|
FileStream | raf |
The file right before the signature is added (can be null). More... |
|
byte[] | bout |
The bytes of the file right before the signature is added (if raf is null). More... |
|
long[] | range |
Array containing the byte positions of the bytes that need to be hashed. More... |
|
PdfDocument | document |
The PdfDocument. More... |
|
PdfSignature | cryptoDictionary |
The crypto dictionary. More... |
|
PdfSigner.ISignatureEvent | signatureEvent |
Holds value of property signatureEvent. More... |
|
Stream | originalOS |
OutputStream for the bytes of the document. More... |
|
MemoryStream | temporaryOS |
Outputstream that temporarily holds the output in memory. More... |
|
FileInfo | tempFile |
Tempfile to hold the output temporarily. More... |
|
IDictionary< PdfName, PdfLiteral > | exclusionLocations |
Name and content of keys that can only be added in the close() method. More... |
|
bool | preClosed = false |
Indicates if the pdf document has already been pre-closed. More... |
|
bool | closed = false |
Boolean to check if this PdfSigner instance has been closed already or not. More... |
|
Takes care of the cryptographic options and appearances that form a signature.
|
strong |
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. |
|
inline |
Creates a PdfSigner instance.
Creates a PdfSigner instance. Uses a System.IO.MemoryStream instead of a temporary file.
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.
|
inline |
Creates a PdfSigner instance.
Creates a PdfSigner instance. Uses a System.IO.MemoryStream instead of a temporary file.
reader | PdfReader that reads the PDF file |
outputStream | OutputStream to write the signed PDF file |
path | File to which the output is temporarily written |
stampingProperties |
iText.Kernel.Pdf.StampingProperties for the signing document. Note that encryption will be preserved regardless of what is set in properties.
signerProperties |
SignerProperties bundled properties to be used in signing operations.
|
inline |
Creates a PdfSigner instance.
Creates a PdfSigner instance. Uses a System.IO.MemoryStream instead of a temporary file.
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.
|
inlinepackagevirtual |
Add developer extension to the current iText.Kernel.Pdf.PdfDocument.
extension |
iText.Kernel.Pdf.PdfDeveloperExtension to be added
|
inlinepackagevirtual |
Adds keys to the signature dictionary that define the certification level and the permissions.
Adds keys to the signature dictionary that define the certification level and the permissions. This method is only used for Certifying signatures.
crypto | the signature dictionary |
|
inlinepackagevirtual |
Adds keys to the signature dictionary that define the field permissions.
Adds keys to the signature dictionary that define the field permissions. This method is only used for signatures that lock fields.
crypto | the signature dictionary |
fieldLock | the iText.Forms.PdfSigFieldLock instance specified the field lock to be set |
|
inlinepackagevirtual |
This is the last method to be called when using external signatures.
This is the last method to be called when using external signatures. The general sequence is: preClose(), getDocumentBytes() and close().
update is a PdfDictionary that must have exactly the same keys as the ones provided in PreClose(System.Collections.Generic.IDictionary
update | a PdfDictionary with the key/value that will fill the holes defined in PreClose(System.Collections.Generic.IDictionary |
|
inlinepackagevirtual |
Creates new signature form field and adds it to the acroForm object.
Creates new signature form field and adds it to the acroForm object. This method is called during the PreClose(System.Collections.Generic.IDictionary
acroForm |
iText.Forms.PdfAcroForm object in which new signature field will be added
name | the name of the field |
|
inlinepackagevirtual |
Check if current document instance already contains certification or approval signatures.
true
if document contains certification or approval signatures, false
otherwise
|
inlinevirtual |
Gets the PdfDocument associated with this instance.
|
inlinevirtual |
Gets a new signature field name that doesn't clash with any existing name.
|
inlinepackagevirtual |
Gets the document bytes that are hashable when using external signatures.
Gets the document bytes that are hashable when using external signatures. The general sequence is: PreClose(System.Collections.Generic.IDictionary
|
inlinepackagevirtual |
Returns final signature appearance object set by SignerProperties.SetSignatureAppearance(iText.Forms.Form.Element.SignatureFieldAppearance) and customized using PdfSigner properties such as signing date, reason, location and signer name in case they weren't specified by the user, or, if none was set, returns a new one with default appearance.
Returns final signature appearance object set by SignerProperties.SetSignatureAppearance(iText.Forms.Form.Element.SignatureFieldAppearance) and customized using PdfSigner properties such as signing date, reason, location and signer name in case they weren't specified by the user, or, if none was set, returns a new one with default appearance.
To customize the appearance of the signature, create new iText.Forms.Form.Element.SignatureFieldAppearance object and set it using SignerProperties.SetSignatureAppearance(iText.Forms.Form.Element.SignatureFieldAppearance).
Note that in case you create new signature field (either use SignerProperties.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.
It is possible to set other appearance related properties such as iText.Forms.Fields.PdfSignatureFormField.SetReuseAppearance(bool) , iText.Forms.Fields.PdfSignatureFormField.SetBackgroundLayer(iText.Kernel.Pdf.Xobject.PdfFormXObject) (n0 layer) and iText.Forms.Fields.PdfSignatureFormField.SetSignatureAppearanceLayer(iText.Kernel.Pdf.Xobject.PdfFormXObject) (n2 layer) for the signature field using GetSignatureField() . Page, rectangle and other properties could be set up via SignerProperties.
iText.Forms.Form.Element.SignatureFieldAppearance object representing signature appearance
|
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.
|
inlinevirtual |
Getter for property signatureEvent.
|
inlinevirtual |
Gets the signature field to be signed.
Gets the signature field to be signed. The field can already be presented in the document. If the field is not presented in the document, it will be created.
This field instance is expected to be used for setting appearance related properties such as iText.Forms.Fields.PdfSignatureFormField.SetReuseAppearance(bool) , iText.Forms.Fields.PdfSignatureFormField.SetBackgroundLayer(iText.Kernel.Pdf.Xobject.PdfFormXObject) and iText.Forms.Fields.PdfSignatureFormField.SetSignatureAppearanceLayer(iText.Kernel.Pdf.Xobject.PdfFormXObject) .
Note that for the new signature field SignerProperties.SetPageRect(iText.Kernel.Geom.Rectangle) and SignerProperties.SetPageNumber(int) should be called before this method.
|
inlinevirtual |
Gets the properties to be used in signing operations.
|
inlinepackagevirtual |
Returns the underlying source.
|
inlinepackagevirtual |
Get the page number associated to the provided widget.
widget | PdfWidgetAnnotation from which to extract the page number |
|
inlinepackagevirtual |
Get the rectangle associated to the provided widget.
widget | PdfWidgetAnnotation to extract the rectangle from |
|
inlinepackagevirtual |
Initialize new iText.Kernel.Pdf.PdfDocument instance by using provided parameters.
reader |
iText.Kernel.Pdf.PdfReader to be used as a reader in the new document
writer |
iText.Kernel.Pdf.PdfWriter to be used as a writer in the new document
properties |
iText.Kernel.Pdf.StampingProperties to be provided in the new document
|
inlinepackagevirtual |
Checks if the document is in the process of closing.
|
inlinepackagevirtual |
Populates already existing signature form field in the acroForm object.
Populates already existing signature form field in the acroForm object. This method is called during the PreClose(System.Collections.Generic.IDictionary
acroForm |
iText.Forms.PdfAcroForm object in which the signature field will be populated
|
inlinepackagevirtual |
This is the first method to be called when using external signatures.
This is the first method to be called when using external signatures. The general sequence is: preClose(), getDocumentBytes() and close().
exclusionSizes
must contain at least the PdfName.CONTENTS
key with the size that it will take in the document. Note that due to the hex string coding this size should be byte_size*2+2.
exclusionSizes | Map with names and sizes to be excluded in the signature calculation. The key is a PdfName and the value an Integer. At least the /Contents must be present |
|
inlinepackagevirtual |
Processes a CRL list.
cert | a Certificate if one of the CrlList implementations needs to retrieve the CRL URL from it. |
crlList | a list of CrlClient implementations |
|
inlinepackagevirtual |
Sets the PdfDocument.
document | The PdfDocument |
|
inlinevirtual |
Setter for the OutputStream.
originalOS | OutputStream for the bytes of the document |
|
inlinevirtual |
Sets the signature event to allow modification of the signature dictionary.
signatureEvent | the signature event |
|
inlinevirtual |
Sets the properties to be used in signing operations.
properties | the signer properties |
|
inlinestatic |
Signs a PDF where space was already reserved.
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 |
|
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.
externalSignature | the interface providing the actual signing |
chain | the certificate chain |
crlList | the CRL list |
ocspClient | the OCSP client |
tsaClient | the Timestamp client |
externalDigest | an implementation that provides the digest |
estimatedSize | the reserved size for the signature. It will be estimated if 0 |
sigtype | Either Signature.CMS or Signature.CADES |
|
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.
externalSignature | the interface providing the actual signing |
chain | the certificate chain |
crlList | the CRL list |
ocspClient | the OCSP client |
tsaClient | the Timestamp client |
externalDigest | an implementation that provides the digest |
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) |
|
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.
externalSignature | the interface providing the actual signing |
chain | the certificate chain |
crlList | the CRL list |
ocspClient | the OCSP client |
tsaClient | the Timestamp client |
externalDigest | an implementation that provides the digest |
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) |
|
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.
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 |
|
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.
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) |
|
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.
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) |
|
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.
externalSignatureContainer | the interface providing the actual signing |
estimatedSize | the reserved size for the signature |
|
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.
tsa | the timestamp generator |
signatureName | the signature name or null to have a name generated automatically |
|
package |
The bytes of the file right before the signature is added (if raf is null).
|
package |
Boolean to check if this PdfSigner instance has been closed already or not.
|
package |
The crypto dictionary.
|
package |
The PdfDocument.
|
package |
Name and content of keys that can only be added in the close() method.
|
package |
OutputStream for the bytes of the document.
|
package |
Indicates if the pdf document has already been pre-closed.
|
package |
The file right before the signature is added (can be null).
|
package |
Array containing the byte positions of the bytes that need to be hashed.
|
package |
Holds value of property signatureEvent.
|
package |
Tempfile to hold the output temporarily.
|
package |
Outputstream that temporarily holds the output in memory.