[SerializableAttribute()]
public class ImageFormFieldResult : FormFieldResult
Fields are defined for each page in the processing engine. All fields require you fill in the Property specifying where the field is located, and a Name Property.
Fields can be added or retrieved through the FormProcessingEngine.Pages property. Once fields are defined, they can be loaded/saved from disk using the FormProcessingEngine.LoadFields and FormProcessingEngine.SaveFields methods, allowing you to define MasterForm fields just once and save them to disk. LEADTOOLS supports TextFormField, OmrFormField, BarcodeFormField, ImageFormField, and custom user-defined fields derived from FormField. When obtaining processing results, check for the type of each field, and cast it to the appropriate type in order to obtain the field specific results (barcode, image, etc).
using Leadtools;
using Leadtools.Barcode;
using Leadtools.Codecs;
using Leadtools.Forms.Common;
using Leadtools.Ocr;
using Leadtools.Forms.Processing;
using Leadtools.Forms.Recognition;
using Leadtools.Forms.Recognition.Barcode;
using Leadtools.Forms.Recognition.Ocr;
using Leadtools.Document;
///This example prints field results.
private string GetDataString(byte[] data)
{
string result = string.Empty;
for (int i = 0; i < data.Length; i++)
{
result = result + System.Convert.ToChar(data[i]).ToString();
}
return result;
}
public void PrintOutFieldResults(FormProcessingEngine processingEngine)
{
foreach (FormPage page in processingEngine.Pages)
{
foreach (FormField field in page)
{
string[] row = new string[5];
row[0] = field.Name;
row[4] = field.Bounds.ToString();
if (field.Result != null)
{
if (field is TextFormField)
{
row[1] = "Text";
row[2] = ((field as TextFormField).Result as TextFormFieldResult).Text;
row[3] = ((field as TextFormField).Result as TextFormFieldResult).AverageConfidence.ToString();
}
else if (field is OmrFormField)
{
row[1] = "Omr";
row[2] = ((field as OmrFormField).Result as OmrFormFieldResult).Text;
row[3] = ((field as OmrFormField).Result as OmrFormFieldResult).AverageConfidence.ToString();
}
else if (field is BarcodeFormField)
{
row[1] = "Barcode";
for (int i = 0; i < ((field as BarcodeFormField).Result as BarcodeFormFieldResult).BarcodeData.Count; i++)
row[2] = GetDataString(((field as BarcodeFormField).Result as BarcodeFormFieldResult).BarcodeData[i].GetData());
row[3] = "N/A";
}
else if (field is ImageFormField)
{
row[1] = "Image";
row[2] = "N/A";
row[3] = "N/A";
}
}
foreach (string line in row)
Console.WriteLine(line + "\r\n");
}
}
}