Skip to main content

IFormFieldCollection Interface

Defines a collection of PDF form fields.

Declaration

public interface IFormFieldCollection extends IObjectCollectionBase<FormField>

Remarks

Use the PdfDocument.getFields() method to access a PDF document’s form field collection. You can iterate through all fields, find a field by name, find fields that match a condition, or locate a field’s parent group.

Refer to the following help topic for additional information: Access and Find PDF Form Fields.

Implements

com.devexpress.docs.pdf.IObjectCollectionBase<com.devexpress.docs.pdf.FormField>

Methods

find(Predicate<FormField> predicate, GroupField[] parentGroup, Runnable parentGroup_sync) Method

Returns the first form field that satisfies the specified condition and its parent group.

Declaration

public abstract FormField find(Predicate<FormField> predicate, GroupField[] parentGroup, Runnable parentGroup_sync)

Parameters

Name Type Description
predicate java.util.function.Predicate<FormField>

The condition used to test form fields.

parentGroup GroupField[]

An output container for the parent group of the returned form field.

parentGroup_sync Runnable

A synchronization callback for the parentGroup output parameter.

Returns

Type Description
FormField

The first form field that satisfies the specified condition, if found.

find(Predicate<FormField> predicate) Method

Returns the first form field that satisfies the specified condition.

Declaration

public abstract FormField find(Predicate<FormField> predicate)

Parameters

Name Type Description
predicate java.util.function.Predicate<FormField>

The condition used to test form fields.

Returns

Type Description
FormField

The first form field that satisfies the specified condition, if found.

Remarks

The following code snippet finds the first field whose name starts with First:

// Find the first matching form field.
FormField field = pdfDocument.getFields().find(
        f -> f.getName().startsWith("First"));

if (field != null) {
    System.out.println(field.getName());
}

findAll(Predicate<FormField> predicate) Method

Returns all form fields that satisfy the specified condition.

Declaration

public abstract List<FormField> findAll(Predicate<FormField> predicate)

Parameters

Name Type Description
predicate java.util.function.Predicate<FormField>

The condition used to test form fields.

Returns

Type Description
java.util.List<FormField>

Form fields that satisfy the specified condition.

Remarks

The following code snippet finds all fields whose names contain Name:

// Find all matching form fields.
Iterable<FormField> fields =
        pdfDocument.getFields().findAll(
                f -> f.getName().contains("Name"));

for (FormField field : fields) {
    System.out.println(field.getName());
}

findByName(String name, GroupField[] parentGroup, Runnable parentGroup_sync) Method

Returns the form field with the specified name and its parent group.

Declaration

public abstract FormField findByName(String name, GroupField[] parentGroup, Runnable parentGroup_sync)

Parameters

Name Type Description
name String

The name of the form field to find.

parentGroup GroupField[]

An output container for the parent group of the returned form field.

parentGroup_sync Runnable

A synchronization callback for the parentGroup output parameter.

Returns

Type Description
FormField

The form field with the specified name, if found.

findByName(String name) Method

Returns the form field with the specified name.

Declaration

public abstract FormField findByName(String name)

Parameters

Name Type Description
name String

The name of the form field to find.

Returns

Type Description
FormField

The form field with the specified name, if found.

Remarks

The following code snippet searches for the FirstName field:

// Find a form field by name.
FormField field = pdfDocument.getFields().findByName("FirstName");

if (field != null) {
    System.out.println(field.getName());
}

findParent(FormField field) Method

Returns the parent group of the specified form field.

Declaration

public abstract GroupField findParent(FormField field)

Parameters

Name Type Description
field FormField

The form field.

Returns

Type Description
GroupField

The parent group of the specified form field, if it exists.

Remarks

The following code snippet obtains the parent group of a form field:

// Find a form field.
FormField field = pdfDocument.getFields().findByName("FirstName");

// Get the parent group.
GroupField group = pdfDocument.getFields().findParent(field);

if (group != null) {
    System.out.println(group.getName());
}

toFlatIterable() Method

Returns a flattened collection that contains all fields in the document.

Declaration

public abstract Iterable<FormField> toFlatIterable()

Returns

Type Description
java.lang.Iterable<FormField>

A flattened collection that contains all fields in the document.