Creates a new BubbleWordField with automatically filled out field values.
public BubbleWordField CreateBubbleWordField(
RasterImage image,
List<FormField> formFields,
LeadRect bounds,
int formPageNumber
)
image
The master form image.
formFields
A FormField list that contains all fields, including the OmrFormField fields within the bounds.
bounds
A LeadRect represents the location of the BubbleWordField to be created.
formPageNumber
Master form page number.
A BubbleWordField field with automatically filled out field values.
If the row count is 26 the field values are filled with alphabets from A to Z and the BubbleWordValueType is set to Character. Otherwise, the field values are filled with numbers from 0 to the row count and the BubbleWordValueType is set to Numerical.
using Leadtools;
using Leadtools.Ocr;
using Leadtools.Forms.Common;
using Leadtools.Forms.Processing;
using Leadtools.Codecs;
using Leadtools.Forms.Auto;
///This example shows how to create a BubbleWordField.
public void AddBubbleWordField()
{
DiskMasterForm diskMasterForm = GetMasterForm("LeadAnswerSheet_Pattern");
FormPages formPages = diskMasterForm.ReadFields();
List<FormField> omrFields = GetOmrFields(formPages);
LeadRect bounds = new LeadRect(225, 5110, 2025, 1030);
//Automatically create BubbleWordField
BubbleWordField bubbleWordField = diskMasterForm.CreateBubbleWordField(diskMasterForm.ReadForm(), omrFields, bounds, 1);
// Set field name
bubbleWordField.Name = "StudentID";
formPages.GetPage(1).Add(bubbleWordField);
// Write fields to master form
diskMasterForm.WriteFields(formPages);
}
private DiskMasterForm GetMasterForm(string name)
{
string root = Path.Combine(LEAD_VARS.ImagesDir, @"Forms\MasterForm Sets\OMR");
RasterCodecs codecs = new RasterCodecs();
//create repository
DiskMasterFormsRepository repository = new DiskMasterFormsRepository(codecs, root);
foreach (IMasterForm masterForm in repository.RootCategory.MasterForms)
{
if (masterForm.Name.Equals(name))
{
return masterForm as DiskMasterForm;
}
}
return null;
}
private List<FormField> GetOmrFields(FormPages formPages)
{
List<FormField> fields = new List<FormField>();
FormPage formPage = formPages.GetPage(1);
foreach (FormField field in formPage)
{
if (field is OmrFormField)
{
fields.Add(field);
}
}
return fields;
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";
}