GetFieldsByName

DocumentData.GetFieldsByName method

Returns the collection of field data where the name is equal to fieldName.

public IList<FieldData> GetFieldsByName(string fieldName)
Parameter Type Description
fieldName String The name of the field.

Return Value

A collection of FieldData objects; empty collection if no field data is found.

Examples

Find fields by a field name:

// Get all the fields with "Address" name
IList<FieldData> addressFields = data.GetFieldsByName("Address");
if(addressFields.Count == 0) {
    Console.WriteLine("Address not found");
}
else {
    Console.WriteLine("Address");
    // Iterate over the fields collection
    for (int i = 0; i < addressFields.Count; i++) {
        PageTextArea area = addressFields[i].PageArea as PageTextArea;
        Console.WriteLine(area == null ? "Not a template field" : area.Text);       
         
        // If it's a related field:
        if(addressFields[i].LinkedField != null) {
            Console.Write("Linked to ");
            PageTextArea linkedArea = addressFields[i].LinkedField.PageArea as PageTextArea;
            Console.WriteLine(area == null ? "Not a template field" : area.Text);           
        }
    }
}

FieldData class represents field data. Depending on the field PageArea property can contain any of the inheritors of PageArea class. For example, ParseForm method extracts only text fields.

See Also