Class PdfLoadedSignatureField
Represents the signature field of an existing PDF document.
Implements
Inherited Members
Namespace: Syncfusion.Pdf.Parsing
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfLoadedSignatureField : PdfLoadedStyledField, IPdfWrapper, INotifyPropertyChanged
Examples
//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Gets the signature field
PdfLoadedSignatureField signatureField = doc.Form.Fields["ManagerSignature"] as PdfLoadedSignatureField;
signatureField.Flatten = true;
doc.Save("LoadedForm.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Gets the signature field
Dim signatureField As PdfLoadedSignatureField = TryCast(doc.Form.Fields("ManagerSignature"), PdfLoadedSignatureField)
signatureField.Flatten = True
doc.Save("LoadedForm.pdf")
doc.Close(True)
Properties
IsSigned
Checks whether the signature field is signed or not
Declaration
public bool IsSigned { get; }
Property Value
Type | Description |
---|---|
System.Boolean | A boolean value specifying the digital signature field have signature data or not. |
Examples
//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Read the first page
PdfPageBase page = doc.Pages[0];
// Gets the signature field
PdfLoadedSignatureField signatureField = doc.Form.Fields["ManagerSignature"] as PdfLoadedSignatureField;
// Checks whether the signature field is signed or not
bool isSigned = signatureField.IsSigned;
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Read the first page
Dim page As PdfPageBase = doc.Pages(0)
' Gets the signature field
Dim signatureField As PdfLoadedSignatureField = TryCast(doc.Form.Fields("ManagerSignature"), PdfLoadedSignatureField)
' Checks whether the signature field is signed or not
Dim isSigned As Boolean = signatureField.IsSigned
doc.Close(True)
See Also
Items
Gets the collection of signature items.[Read-Only]
Declaration
public PdfLoadedSignatureItemCollection Items { get; }
Property Value
Type |
---|
PdfLoadedSignatureItemCollection |
Examples
//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Read the signature field
PdfLoadedSignatureField signatureField = doc.Form.Fields[0] as PdfLoadedSignatureField;
// Signature Item collection
PdfLoadedSignatureItemCollection signatureFieldCollection = signatureField.Items;
// Read the signature Item
PdfLoadedSignatureItem signatureFieldItem = signatureFieldCollection[0] as PdfLoadedSignatureItem;
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Read the signature field
Dim signatureField As PdfLoadedSignatureField = TryCast(doc.Form.Fields(0), PdfLoadedSignatureField)
' Signature Item collection
Dim signatureFieldCollection As PdfLoadedSignatureItemCollection = signatureField.Items
Dim signatureFieldItem As PdfLoadedSignatureItem = TryCast(signatureFieldCollection(0), PdfLoadedSignatureItem)
doc.Save("Form.pdf")
doc.Close(True)
See Also
Revision
Gets the revision index of this signature field.
Declaration
public int Revision { get; }
Property Value
Type |
---|
System.Int32 |
Remarks
If the signature field is "Unsigned," the revision value will be -1.
Examples
//Loads an existing document
PdfLoadedDocument document = new PdfLoadedDocument(filename);
//Gets the revisions of the document
PdfRevision[] revisions = document.Revisions;
foreach(PdfRevision rev in revisions)
{
//Gets the revision start position
long startPosition = rev.StartPosition;
}
//Load the existing signature field
PdfLoadedSignatureField field = document.Form.Fields[0] as PdfLoadedSignatureField;
//Gets the revision index of the signature
int revisionIndex = field.Revision;
// Close the document
document.Close(true);
'Loads an existing document
Dim document As PdfLoadedDocument = New PdfLoadedDocument(filename)
'Gets the revisions of the document
Dim revisions() As PdfRevision = document.Revisions
For Each rev As PdfRevision In revisions
'Gets the revision start position
Dim startPosition As Long = rev.StartPosition
Next
'Load the existing signature field
Dim field As PdfLoadedSignatureField = CType(document.Form.Fields(0),PdfLoadedSignatureField)
'Gets the revision index of the signature
Dim revisionIndex As Integer = field.Revision
' Close the document
document.Close(true)
Signature
Gets or sets the digital signature for signing the field.
Declaration
public PdfSignature Signature { get; set; }
Property Value
Type | Description |
---|---|
PdfSignature | A PdfSignature object specifying the digital signature for signing the field. |
Examples
//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Read the first page
PdfPageBase page = doc.Pages[0];
// Gets the signature field
PdfLoadedSignatureField signatureField = doc.Form.Fields["ManagerSignature"] as PdfLoadedSignatureField;
// Create a new Signature
PdfCertificate pdfCert = new PdfCertificate("Pdf.pfx", "123");
PdfSignature signature = new PdfSignature(doc, page, pdfCert, "Signature");
signature.Bounds = new RectangleF(new PointF(5, 5), new SizeF(100, 200));
// Set the signature of the field
signatureField.Signature = signature;
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Read the first page
Dim page As PdfPageBase = doc.Pages(0)
' Gets the signature field
Dim signatureField As PdfLoadedSignatureField = TryCast(doc.Form.Fields("ManagerSignature"), PdfLoadedSignatureField)
' Create a new Signature
Dim pdfCert As PdfCertificate = New PdfCertificate("Pdf.pfx", "123")
Dim signature As PdfSignature = New PdfSignature(doc, page, pdfCert, "Signature")
signature.Bounds = New RectangleF(New PointF(5, 5), New SizeF(100, 200))
' Set the signature of the field
signatureField.Signature = signature
doc.Save("Form.pdf")
doc.Close(True)
See Also
Methods
GetImages()
Returns an array of images objects that represent the images associated with the signature field.
Declaration
public Image[] GetImages()
Returns
Type | Description |
---|---|
System.Drawing.Image[] | An array of image objects that represent the images associated with the signature field |
Examples
//Load the existing PDF document.
PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf");
//Get the existing signed signature field.
PdfLoadedSignatureField loadedSignature = ldoc.Forms.Fields[0] as PdfLoadedSignatureField;
//Get the image arrays
Image[] images = loadedSignature.GetImages();
//Close the PDF document.
ldoc.Close(true);
ValidateSignature()
Specifies the signatures's validation result.
Declaration
public PdfSignatureValidationResult ValidateSignature()
Returns
Type |
---|
PdfSignatureValidationResult |
Examples
// Loads an existing document
PdfLoadedDocument document = new PdfLoadedDocument(fileName);
// Gets the signature field
PdfLoadedSignatureField signatureField = document.Form.Fields[0] as PdfLoadedSignatureField;
// Validate signature and get validation result
PdfSignatureValidationResult result = signatureField.ValidateSignature();
// Close the document
document.Close(true);
' Loads an existing document
Dim document As PdfLoadedDocument = New PdfLoadedDocument(fileName)
' Gets the signature field
Dim signatureField As PdfLoadedSignatureField = document.Form.Fields[0] As PdfLoadedSignatureField
' Validate signature and get validation result
Dim result As PdfSignatureValidationResult = signatureField.ValidateSignature()
' Close the document
document.Close(true)
ValidateSignature(PdfSignatureValidationOptions)
Specifies the signatures's validation result with validation option
Declaration
public PdfSignatureValidationResult ValidateSignature(PdfSignatureValidationOptions options)
Parameters
Type | Name | Description |
---|---|---|
PdfSignatureValidationOptions | options |
Returns
Type |
---|
PdfSignatureValidationResult |
Examples
// Loads an existing document
PdfLoadedDocument document = new PdfLoadedDocument(fileName);
// Gets the signature field
PdfLoadedSignatureField signatureField = document.Form.Fields[0] as PdfLoadedSignatureField;
// Signature validation options
PdfSignatureValidationOptions options = new PdfSignatureValidationOptions();
// disable revocation status
options.ValidateRevocationStatus = false;
// Validate signature and get validation result
PdfSignatureValidationResult result = signatureField.ValidateSignature(options);
// Close the document
document.Close(true);
' Loads an existing document
Dim document As PdfLoadedDocument = New PdfLoadedDocument(fileName)
' Gets the signature field
Dim signatureField As PdfLoadedSignatureField = document.Form.Fields[0] As PdfLoadedSignatureField
' Signature validation options
Dim options As PdfSignatureValidationOptions = New PdfSignatureValidationOptions()
' disable revocation status
options.ValidateRevocationStatus = False
' Validate signature and get validation result
Dim result As PdfSignatureValidationResult = signatureField.ValidateSignature(options)
' Close the document
document.Close(true)
ValidateSignature(X509CertificateCollection)
Specifies the signatures's validation result with X509Certificate collection.
Declaration
public PdfSignatureValidationResult ValidateSignature(X509CertificateCollection rootCertificates)
Parameters
Type | Name | Description |
---|---|---|
System.Security.Cryptography.X509Certificates.X509CertificateCollection | rootCertificates |
Returns
Type |
---|
PdfSignatureValidationResult |
Examples
// Loads an existing document
PdfLoadedDocument document = new PdfLoadedDocument(fileName);
// Gets the signature field
PdfLoadedSignatureField signatureField = document.Form.Fields[0] as PdfLoadedSignatureField;
// Collection of X509Certificate
X509CertificateCollection certificates = new X509CertificateCollection();
certificates.Add(X509Certificate.CreateFromCertFile("certificate1.cer"));
certificates.Add(X509Certificate.CreateFromCertFile("certificate2.cer"))
// Validate signature and get validation result
PdfSignatureValidationResult result = signatureField.ValidateSignature(certificates);
// Close the document
document.Close(true);
' Loads an existing document
Dim document As PdfLoadedDocument = New PdfLoadedDocument(fileName)
' Gets the signature field
Dim signatureField As PdfLoadedSignatureField = document.Form.Fields[0] As PdfLoadedSignatureField
' Collection of X509Certificate
Dim certificates As X509CertificateCollection = New X509CertificateCollection()
certificates.Add(X509Certificate.CreateFromCertFile("certificate1.cer"))
certificates.Add(X509Certificate.CreateFromCertFile("certificate2.cer"))
' Validate signature and get validation result
Dim result As PdfSignatureValidationResult = signatureField.ValidateSignature(certificates)
' Close the document
document.Close(true)
ValidateSignature(X509CertificateCollection, PdfSignatureValidationOptions)
Specifies the signatures's validation result with X509Certificate collection with validation option
Declaration
public PdfSignatureValidationResult ValidateSignature(X509CertificateCollection rootCertificates, PdfSignatureValidationOptions options)
Parameters
Type | Name | Description |
---|---|---|
System.Security.Cryptography.X509Certificates.X509CertificateCollection | rootCertificates | |
PdfSignatureValidationOptions | options |
Returns
Type |
---|
PdfSignatureValidationResult |
Examples
// Loads an existing document
PdfLoadedDocument document = new PdfLoadedDocument(fileName);
// Gets the signature field
PdfLoadedSignatureField signatureField = document.Form.Fields[0] as PdfLoadedSignatureField;
// Collection of X509Certificate
X509CertificateCollection certificates = new X509CertificateCollection();
certificates.Add(X509Certificate.CreateFromCertFile("certificate1.cer"));
certificates.Add(X509Certificate.CreateFromCertFile("certificate2.cer"))
PdfSignatureValidationOptions options = new PdfSignatureValidationOptions();
// disable revocation status
options.ValidateRevocationStatus = false;
// Validate signature and get validation result
PdfSignatureValidationResult result = signatureField.ValidateSignature(certificates, options);
// Close the document
document.Close(true);
' Loads an existing document
Dim document As PdfLoadedDocument = New PdfLoadedDocument(fileName)
' Gets the signature field
Dim signatureField As PdfLoadedSignatureField = document.Form.Fields[0] As PdfLoadedSignatureField
' Collection of X509Certificate
Dim certificates As X509CertificateCollection = New X509CertificateCollection()
certificates.Add(X509Certificate.CreateFromCertFile("certificate1.cer"))
certificates.Add(X509Certificate.CreateFromCertFile("certificate2.cer"))
' Signature validation options
Dim options As PdfSignatureValidationOptions = New PdfSignatureValidationOptions()
' disable revocation status
options.ValidateRevocationStatus = False
' Validate signature and get validation result
Dim result As PdfSignatureValidationResult = signatureField.ValidateSignature(certificates, options)
' Close the document
document.Close(true)