←Select platform

CreateBubbleWordField Method

Summary

Creates a new BubbleWordField with automatically filled out field values.

Syntax
C#
C++/CLI
Python
public BubbleWordField CreateBubbleWordField( 
   RasterImage image, 
   List<FormField> formFields, 
   LeadRect bounds, 
   int formPageNumber 
) 
public:  
   BubbleWordField^ CreateBubbleWordField( 
      RasterImage^ image, 
      List<FormField^>^ formFields, 
      LeadRect^ bounds, 
      Int32 formPageNumber 
   ) 
def CreateBubbleWordField(self,image,formFields,bounds,formPageNumber): 

Parameters

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.

Return Value

A BubbleWordField field with automatically filled out field values.

Remarks

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.

Example
C#
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"; 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Forms.Auto Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.