Class SignatureUtil
- Namespace
- iText.Signatures
- Assembly
- itext.sign.dll
Utility class that provides several convenience methods concerning digital signatures.
public class SignatureUtil
- Inheritance
-
SignatureUtil
- Inherited Members
Constructors
SignatureUtil(PdfDocument)
Creates a SignatureUtil instance.
public SignatureUtil(PdfDocument document)
Parameters
document
PdfDocumentPdfDocument to be inspected
Remarks
Creates a SignatureUtil instance. Sets the acroForm field to the acroForm in the PdfDocument. iText will create a new AcroForm if the PdfDocument doesn't contain one.
Methods
DoesSignatureFieldExist(string)
Checks whether a name exists as a signature field or not.
public virtual bool DoesSignatureFieldExist(string name)
Parameters
name
stringname of the field
Returns
- bool
boolean does the signature field exist
Remarks
Checks whether a name exists as a signature field or not. It checks both signed fields and blank signatures.
ExtractRevision(string)
Extracts a revision from the document.
public virtual Stream ExtractRevision(string field)
Parameters
field
stringthe signature field name
Returns
- Stream
an InputStream covering the revision. Returns null if it's not a signature field
GetBlankSignatureNames()
Gets the field names that have blank signatures.
public virtual IList<string> GetBlankSignatureNames()
Returns
GetRevision(string)
Get signed document revision number, which corresponds to the provided signature name.
public virtual int GetRevision(string field)
Parameters
field
stringsignature name
Returns
- int
int
revision number
GetSignature(string)
Get PdfSignature dictionary based on the provided name.
public virtual PdfSignature GetSignature(string name)
Parameters
name
stringsignature name
Returns
- PdfSignature
PdfSignature instance corresponding to the provided name. null otherwise
GetSignatureDictionary(string)
Gets the signature dictionary, the one keyed by /V.
public virtual PdfDictionary GetSignatureDictionary(string name)
Parameters
name
stringthe field name
Returns
- PdfDictionary
the signature dictionary keyed by /V or
null
if the field is not a signature
GetSignatureFormFieldDictionary(string)
public virtual PdfDictionary GetSignatureFormFieldDictionary(string name)
Parameters
name
string
Returns
GetSignatureNames()
Gets the field names that have signatures and are signed.
public virtual IList<string> GetSignatureNames()
Returns
GetTotalRevisions()
Get the amount of signed document revisions.
public virtual int GetTotalRevisions()
Returns
- int
int
amount of signed document revisions
GetTranslatedFieldName(string)
Get field name, translated using XFA, if any present in the document.
public virtual string GetTranslatedFieldName(string name)
Parameters
name
stringfield name to be translated
Returns
- string
translated field name if XFA is present, original name otherwise
ReadSignatureData(string)
Prepares an PdfPKCS7 instance for the given signature.
public virtual PdfPKCS7 ReadSignatureData(string signatureFieldName)
Parameters
signatureFieldName
stringthe signature field name
Returns
- PdfPKCS7
a PdfPKCS7 instance which can be used to fetch additional info about the signature and also to perform integrity check of data signed by the given signature field.
Remarks
Prepares an PdfPKCS7 instance for the given signature. This method handles signature parsing and might throw an exception if signature is malformed.
The returned PdfPKCS7 can be used to fetch additional info about the signature and also to perform integrity check of data signed by the given signature field. Prepared PdfPKCS7 instance calculates digest based on signature's /ByteRange entry. In order to check that /ByteRange is properly defined and given signature indeed covers the current PDF document revision please use SignatureCoversWholeDocument(string) method.SignatureCoversWholeDocument(string)
Checks if the signature covers the entire document (except for signature's Contents) or just a part of it.
public virtual bool SignatureCoversWholeDocument(string name)
Parameters
name
stringthe signature field name
Returns
- bool
true if the signature covers the entire document, false if it doesn't
Remarks
Checks if the signature covers the entire document (except for signature's Contents) or just a part of it.
If this method does not return true it means that signature in question does not cover the entire contents of current PdfDocument . Such signatures cannot be considered as verifying the PDF document, because content that is not covered by signature might have been modified since the signature creation.