menu

Xamarin.Android

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class PdfLoadedFormFieldCollection - Xamarin.Android API Reference | Syncfusion

    Show / Hide Table of Contents

    Class PdfLoadedFormFieldCollection

    Represents field collection of loaded form.

    Inheritance
    System.Object
    PdfCollection
    PdfFieldCollection
    PdfLoadedFormFieldCollection
    Implements
    System.Collections.IEnumerable
    Inherited Members
    PdfCollection.Count
    PdfCollection.GetEnumerator()
    PdfCollection.List
    PdfFieldCollection.Add(PdfField)
    PdfFieldCollection.Clear()
    PdfFieldCollection.Contains(PdfField)
    PdfFieldCollection.DoAdd(PdfXfaForm, String)
    PdfFieldCollection.IndexOf(PdfField)
    PdfFieldCollection.Insert(Int32, PdfField)
    PdfFieldCollection.Remove(PdfField)
    PdfFieldCollection.RemoveAt(Int32)
    Namespace: Syncfusion.Pdf.Parsing
    Assembly: Syncfusion.Pdf.Portable.dll
    Syntax
    public class PdfLoadedFormFieldCollection : PdfFieldCollection, IEnumerable, IPdfWrapper
    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.

    Declaration
    public PdfLoadedFormFieldCollection()

    PdfLoadedFormFieldCollection(PdfLoadedForm)

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

    Declaration
    public PdfLoadedFormFieldCollection(PdfLoadedForm form)
    Parameters
    Type Name Description
    PdfLoadedForm form

    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)

    Properties

    Form

    Gets or sets the form.

    Declaration
    public PdfLoadedForm Form { get; set; }
    Property Value
    Type
    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)

    Item[Int32]

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

    Declaration
    public override PdfField this[int index] { get; }
    Parameters
    Type Name Description
    System.Int32 index
    Property Value
    Type
    PdfField
    Overrides
    PdfFieldCollection.Item[Int32]
    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
    PdfLoadedDocument

    Item[String]

    Returns field with specified name.[Read-Only]

    Declaration
    public PdfField this[string name] { get; }
    Parameters
    Type Name Description
    System.String name

    The specified field name.

    Property Value
    Type
    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)

    Methods

    DoAdd(PdfField)

    Adds a field to collection.

    Declaration
    protected override int DoAdd(PdfField field)
    Parameters
    Type Name Description
    PdfField field

    The field.

    Returns
    Type
    System.Int32
    Overrides
    PdfFieldCollection.DoAdd(PdfField)

    DoClear()

    Clears the collection.

    Declaration
    protected override void DoClear()
    Overrides
    PdfFieldCollection.DoClear()

    DoInsert(Int32, PdfField)

    Inserts a filed into collection.

    Declaration
    protected override void DoInsert(int index, PdfField field)
    Parameters
    Type Name Description
    System.Int32 index

    The index.

    PdfField field

    The field.

    Overrides
    PdfFieldCollection.DoInsert(Int32, PdfField)

    DoRemove(PdfField)

    Removes the field from collection.

    Declaration
    protected override void DoRemove(PdfField field)
    Parameters
    Type Name Description
    PdfField field

    The field.

    Overrides
    PdfFieldCollection.DoRemove(PdfField)

    DoRemoveAt(Int32)

    Removes the field at the specified position.

    Declaration
    protected override void DoRemoveAt(int index)
    Parameters
    Type Name Description
    System.Int32 index

    The index.

    Overrides
    PdfFieldCollection.DoRemoveAt(Int32)

    TryGetField(String, out PdfLoadedField)

    Gets the form field with the given field name

    Declaration
    public bool TryGetField(string fieldName, out PdfLoadedField field)
    Parameters
    Type Name Description
    System.String fieldName

    Name of the field

    PdfLoadedField field

    Loaded Form Field

    Returns
    Type Description
    System.Boolean

    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) 

    TryGetValue(String, out String)

    Gets the filed value from the given field name

    Declaration
    public bool TryGetValue(string fieldName, out string fieldValue)
    Parameters
    Type Name Description
    System.String fieldName

    Name of the loaded form filed

    System.String fieldValue

    Value of the field

    Returns
    Type Description
    System.Boolean

    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) 

    ValidateSignatures(PdfSignatureValidationOptions, out List<PdfSignatureValidationResult>)

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

    Declaration
    public bool ValidateSignatures(PdfSignatureValidationOptions options, out List<PdfSignatureValidationResult> results)
    Parameters
    Type Name Description
    PdfSignatureValidationOptions options
    System.Collections.Generic.List<PdfSignatureValidationResult> results

    The result.

    Returns
    Type
    System.Boolean
    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)

    ValidateSignatures(out List<PdfSignatureValidationResult>)

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

    Declaration
    public bool ValidateSignatures(out List<PdfSignatureValidationResult> results)
    Parameters
    Type Name Description
    System.Collections.Generic.List<PdfSignatureValidationResult> results
    Returns
    Type
    System.Boolean
    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)

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

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

    Declaration
    public bool ValidateSignatures(X509Certificate2Collection rootCertificates, PdfSignatureValidationOptions options, out List<PdfSignatureValidationResult> results)
    Parameters
    Type Name Description
    System.Security.Cryptography.X509Certificates.X509Certificate2Collection rootCertificates

    The root certificate value.

    PdfSignatureValidationOptions options
    System.Collections.Generic.List<PdfSignatureValidationResult> results

    The result value.

    Returns
    Type
    System.Boolean
    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)

    ValidateSignatures(X509Certificate2Collection, out List<PdfSignatureValidationResult>)

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

    Declaration
    public bool ValidateSignatures(X509Certificate2Collection rootCertificates, out List<PdfSignatureValidationResult> results)
    Parameters
    Type Name Description
    System.Security.Cryptography.X509Certificates.X509Certificate2Collection rootCertificates
    System.Collections.Generic.List<PdfSignatureValidationResult> results
    Returns
    Type
    System.Boolean
    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)

    Implements

    System.Collections.IEnumerable

    See Also

    PdfFieldCollection
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved