Table of Contents

Class PdfLoadedFormFieldCollection

Namespace
Syncfusion.Pdf.Parsing
Assembly
Syncfusion.Pdf.Portable.dll

Represents field collection of loaded form.

public class PdfLoadedFormFieldCollection : PdfFieldCollection, IEnumerable
Inheritance
PdfLoadedFormFieldCollection
Implements
Inherited Members

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// PDF loaded field collection
PdfLoadedFormFieldCollection fieldCollection = doc.Form.Fields;
// Remove the first field 
fieldCollection.RemoveAt(0);
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' PDF loaded field collection
Dim fieldCollection As PdfLoadedFormFieldCollection = doc.Form.Fields
' Remove the first field 
fieldCollection.RemoveAt(0)
doc.Save("Form.pdf")
doc.Close(True)

Constructors

PdfLoadedFormFieldCollection()

Initialize the new instance of the PdfLoadedFormFieldCollection class.

public PdfLoadedFormFieldCollection()
See Also

PdfLoadedFormFieldCollection(PdfLoadedForm)

Initializes a new instance of the PdfLoadedFormFieldCollection class with the specific PdfLoadedForm.

public PdfLoadedFormFieldCollection(PdfLoadedForm form)

Parameters

form PdfLoadedForm

The PDF loaded form.

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("Form.pdf");
//Load the existing PDF form.
PdfLoadedForm form = doc.Form;
//Create a new form fields collection instance.
PdfLoadedFormFieldCollection collection = new PdfLoadedFormFieldCollection(form);
//Remove field.
collection.RemoveAt(0);
//Save and close the document.
doc.Save("output.pdf");
doc.Close(true);
'Load an existing document
Dim doc As New PdfLoadedDocument("Form.pdf")
'Load the existing PDF form.
Dim form As PdfLoadedForm = doc.Form
'Create a new form fields collection instance.
Dim collection As New PdfLoadedFormFieldCollection(form)
'Remove field.
collection.RemoveAt(0)
'Save and close the document.
doc.Save("output.pdf")
doc.Close(True)
See Also

Properties

Form

Gets or sets the form.

public PdfLoadedForm Form { get; set; }

Property Value

PdfLoadedForm

Examples

// Loads an existing PDF document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Load the FirstTextBox field
PdfField field = doc.Form.Fields["FirstTextBox"];
field.Flatten = true;
doc.Save("Form.pdf");
doc.Close(true);
 // Loads an existing PDF document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Load the FirstTextBox field
Dim field As PdfField = doc.Form.Fields("FirstTextBox")
field.Flatten = True
doc.Save("Form.pdf")
doc.Close(True)
See Also

this[int]

Gets the PdfField at the specified index.[Read-Only]

public override PdfField this[int index] { get; }

Parameters

index int

Property Value

PdfField

Examples

PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
//load the form fields
foreach (PdfField field in doc.Form.Fields)
{
  // Flatten the form
  field.Flatten = true;
}
doc.Save("Form.pdf");
doc.Close(true);
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
'load the form fields
For Each field As PdfField In doc.Form.Fields
  ' Flatten the form
  field.Flatten = True
Next field
doc.Save("Form.pdf")
doc.Close(True)
See Also

this[string]

Returns field with specified name.[Read-Only]

public PdfField this[string name] { get; }

Parameters

name string

The specified field name.

Property Value

PdfField

Examples

// Loads an existing PDF document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Load the FirstTextBox field
PdfField field = doc.Form.Fields["FirstTextBox"];
field.Flatten = true;
doc.Save("Form.pdf");
doc.Close(true);
 // Loads an existing PDF document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Load the FirstTextBox field
Dim field As PdfField = doc.Form.Fields("FirstTextBox")
field.Flatten = True
doc.Save("Form.pdf")
doc.Close(True)
See Also

Methods

DoAdd(PdfField)

Adds a field to collection.

protected override int DoAdd(PdfField field)

Parameters

field PdfField

The field.

Returns

int
See Also

DoClear()

Clears the collection.

protected override void DoClear()
See Also

DoInsert(int, PdfField)

Inserts a filed into collection.

protected override void DoInsert(int index, PdfField field)

Parameters

index int

The index.

field PdfField

The field.

See Also

DoRemove(PdfField)

Removes the field from collection.

protected override void DoRemove(PdfField field)

Parameters

field PdfField

The field.

See Also

DoRemoveAt(int)

Removes the field at the specified position.

protected override void DoRemoveAt(int index)

Parameters

index int

The index.

See Also

TryGetField(string, out PdfLoadedField)

Gets the form field with the given field name

public bool TryGetField(string fieldName, out PdfLoadedField field)

Parameters

fieldName string

Name of the field

field PdfLoadedField

Loaded Form Field

Returns

bool

True, if form field exists, else False.

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("Form.pdf");
//Load the existing PDF form.
PdfLoadedFormFieldCollection fields = doc.Form.Fields;
PdfLoadedField field = null;
//Get the specific field by name.
fields.TryGetField("fn", out field);
//Set text.
(field as PdfLoadedTextBoxField).Text = "Modified";
//Save and close the document.
doc.Save("output.pdf");
doc.Close(true);
'Load an existing document
Dim doc As New PdfLoadedDocument("Form.pdf")
'Load the existing PDF form.
Dim fields As PdfLoadedFormFieldCollection = doc.Form.Fields
Dim field As PdfLoadedField = Nothing
'Get the specific field by name.
fields.TryGetField("fn", field)
'Set text.
TryCast(field, PdfLoadedTextBoxField).Text = "Modified"
'Save and close the document.
doc.Save("output.pdf")
doc.Close(True)
See Also

TryGetValue(string, out string)

Gets the filed value from the given field name

public bool TryGetValue(string fieldName, out string fieldValue)

Parameters

fieldName string

Name of the loaded form filed

fieldValue string

Value of the field

Returns

bool

True, if form field exists with the specific name, else False.

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("Form.pdf");
//Load the existing PDF form.
PdfLoadedFormFieldCollection fields = doc.Form.Fields;
string fieldValue = null;
//Get the specific field value by name.
fields.TryGetValue("fn", out fieldValue);  
//Save and close the document.
doc.Save("output.pdf");
doc.Close(true);
'Load an existing document
Dim doc As New PdfLoadedDocument("Form.pdf")
'Load the existing PDF form.
Dim fields As PdfLoadedFormFieldCollection = doc.Form.Fields
Dim fieldValue As String = Nothing
'Get the specific field value by name.
fields.TryGetValue("fn", fieldValue)
'Save and close the document.
doc.Save("output.pdf")
doc.Close(True)
See Also

ValidateSignatures(PdfSignatureValidationOptions, out List<PdfSignatureValidationResult>)

Validate all signatures and specifies the signatures's validation result with validation option

public bool ValidateSignatures(PdfSignatureValidationOptions options, out List<PdfSignatureValidationResult> results)

Parameters

options PdfSignatureValidationOptions
results List<PdfSignatureValidationResult>

Returns

bool

Examples

// Loads an existing document
PdfLoadedDocument document = new PdfLoadedDocument(fileName);
// Signature validation options
PdfSignatureValidationOptions options = new PdfSignatureValidationOptions();
// disable revocation status
options.ValidateRevocationStatus = false;
// Validate all signatures and get validation result
List<PdfSignatureValidationResult> results = new List<PdfSignatureValidationResult>();
bool isValid = document.Form.Fields.ValidateSignatures(options, out results);
// Close the document
document.Close(true);
' Loads an existing document
Dim document As PdfLoadedDocument = New PdfLoadedDocument(fileName)
' Signature validation options
Dim options As PdfSignatureValidationOptions = New PdfSignatureValidationOptions()
' disable revocation status
options.ValidateRevocationStatus = False
' Validate all signatures and get validation result
Dim results As New List(Of PdfSignatureValidationResult)()
Dim isValid As Boolean = document.Form.Fields.ValidateSignatures(options, out results)
' Close the document
document.Close(true)
See Also

ValidateSignatures(out List<PdfSignatureValidationResult>)

Validate all signatures and specifies the signatures's validation result.

public bool ValidateSignatures(out List<PdfSignatureValidationResult> results)

Parameters

results List<PdfSignatureValidationResult>

Returns

bool

Examples

// Loads an existing document
PdfLoadedDocument document = new PdfLoadedDocument(fileName);
// Validate all signatures and get validation result
List<PdfSignatureValidationResult> results = new List<PdfSignatureValidationResult>();
bool isValid = document.Form.Fields.ValidateSignatures(out results);
// Close the document
document.Close(true);
' Loads an existing document
Dim document As PdfLoadedDocument = New PdfLoadedDocument(fileName)
' Validate all signatures and get validation result
Dim results As New List(Of PdfSignatureValidationResult)()
Dim isValid As Boolean = document.Form.Fields.ValidateSignatures(out results)
' Close the document
document.Close(true)
See Also

ValidateSignatures(X509Certificate2Collection, PdfSignatureValidationOptions, out List<PdfSignatureValidationResult>)

Validate all signatures and specifies the signatures's validation result with X509Certificate collection with validation option

public bool ValidateSignatures(X509Certificate2Collection rootCertificates, PdfSignatureValidationOptions options, out List<PdfSignatureValidationResult> results)

Parameters

rootCertificates X509Certificate2Collection
options PdfSignatureValidationOptions
results List<PdfSignatureValidationResult>

Returns

bool

Examples

// Loads an existing document
PdfLoadedDocument document = new PdfLoadedDocument(fileName);
// Validate all signatures and get validation result
List<PdfSignatureValidationResult> results = new List<PdfSignatureValidationResult>();
// Collection of X509Certificate
X509CertificateCollection certificates = new X509CertificateCollection();
certificates.Add(X509Certificate.CreateFromCertFile("certificate1.cer"));
certificates.Add(X509Certificate.CreateFromCertFile("certificate2.cer"))
// Signature validation options
PdfSignatureValidationOptions options = new PdfSignatureValidationOptions();
// disable revocation status
options.ValidateRevocationStatus = false;
bool isValid = document.Form.Fields.ValidateSignatures(certificates, options, out results);
// Close the document
document.Close(true);
' Loads an existing document
Dim document As PdfLoadedDocument = New PdfLoadedDocument(fileName)
' Validate all signatures and get validation result
Dim results As New List(Of PdfSignatureValidationResult)()
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
Dim isValid As Boolean = document.Form.Fields.ValidateSignatures(certificates, options, out results)
' Close the document
document.Close(true)
See Also

ValidateSignatures(X509Certificate2Collection, out List<PdfSignatureValidationResult>)

Validate all signatures and specifies the signatures's validation result with X509Certificate collection.

public bool ValidateSignatures(X509Certificate2Collection rootCertificates, out List<PdfSignatureValidationResult> results)

Parameters

rootCertificates X509Certificate2Collection
results List<PdfSignatureValidationResult>

Returns

bool

Examples

// Loads an existing document
PdfLoadedDocument document = new PdfLoadedDocument(fileName);
// Validate all signatures and get validation result
List<PdfSignatureValidationResult> results = new List<PdfSignatureValidationResult>();
// Collection of X509Certificate
X509CertificateCollection certificates = new X509CertificateCollection();
certificates.Add(X509Certificate.CreateFromCertFile("certificate1.cer"));
certificates.Add(X509Certificate.CreateFromCertFile("certificate2.cer"))
bool isValid = document.Form.Fields.ValidateSignatures(certificates, out results);
// Close the document
document.Close(true);
' Loads an existing document
Dim document As PdfLoadedDocument = New PdfLoadedDocument(fileName)
' Validate all signatures and get validation result
Dim results As New List(Of PdfSignatureValidationResult)()
Dim certificates As X509CertificateCollection = New X509CertificateCollection()
certificates.Add(X509Certificate.CreateFromCertFile("certificate1.cer"))
certificates.Add(X509Certificate.CreateFromCertFile("certificate2.cer"))
Dim isValid As Boolean = document.Form.Fields.ValidateSignatures(certificates, out results)
' Close the document
document.Close(true)
See Also

See Also