Item

DocumentData indexer

Gets the field data by an index.

public FieldData this[int index] { get; }
Parameter Description
index The zero-based index of the field.

Return Value

An instance of FieldData class.

Examples

Iteration via all the fields:

for (int i = 0; i < data.Count; i++)
{
    Console.Write(data[i].Name + ": ");
    PageTextArea area = data[i].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:

// Create the parser
using (Parser parser = new Parser(filePath))
{
    // Extract data from PDF Form
    DocumentData data = parser.ParseForm();
    // Iterate over extracted fields
    for (int i = 0; i < data.Count; i++)
    {
        // Get the extracted field
        FieldData field = data[i];
        // Print the field name
        Console.Write(field.Name + ": ");
        // Check if the field value is a text and print it
        PageTextArea area = field.PageArea as PageTextArea;
        Console.WriteLine(area == null ? "Not a template field" : area.Text);
    }
}

See Also