Skip to main content

Scripting - Advanced Zone Locator - Creating OMR Zones

Article # 3035590 - Page views: 478


How to create OMR Zones per Script for the Advanced Zone Locator?



Use Case

Sometimes forms have many OMR zones and with the Advanced Zone Locator it can be time consuming to add the OMR zones manually.

Keep in mind that an automatic zone wizard was added in 6.3. You can find the Wizard button in the AZL settings on the sheet Zones. Maybe it is sufficient for you.


This article describes how a single KTM project can be used to create OMR zones quickly. Example:

1 Test_validation.png

  • Format Locator
    2 FL_Area.png
  • Script Locator
    3 SL_CheckboxDetection.png
  • AZL
    4 AZL.png
  • OMR Zone Profile
    5 OMR_Script_Creation.png
  • Format Locator
    This is used to define a region on the document of the CheckBox Group.
    6 CheckBoxGroup.png
  • Script Locator
    This is used to search for and add the OMR zones in the area defined in the format locator, and group them together.
    When testing (i.e., executing the OMR detection and creation) the script locator will ask some questions and display the following dialogues:
    • Check boxes found: 5 Add them to the AZL?
    • Enter the page number on which the OMR group is printed
    • Enter the name of the OMR group — in this example 'Block A Q1'
    • Results
      7 Properties.png
      8_1 Properties.png
      8 Properties.png
  • The AZL has to have a sample document defined, before you test the script locator.
  • After testing, i.e. executing, the script locator the following zones are added to the AZL:
    9 Properties.png
  • Once all OMR groups have been created, then the AZL can be exported and imported to the main project. 10 Icon.png


Sort Box Information

Private Function SortBoxInfos(ByRef BoxInfos() As CscBoxInfo, ByRef iPixelTolerance As Integer)
  Dim Sorted As Boolean
  Dim Condition As Boolean
  Dim i As Integer
  Dim Fst As CscBoxInfo
  Dim Snd As CscBoxInfo
  Dim Temp As CscBoxInfo
  Sorted = False
  Do While Sorted = False
    Sorted = True
    For i = 0 To UBound(BoxInfos) - 1
      Set Fst = BoxInfos(i)
      Set Snd = BoxInfos(i + 1)
      Condition = False
      If Fst.Top < (Snd.Top - iPixelTolerance) Then
         Condition = False
      ElseIf Fst.Top > (Snd.Top + iPixelTolerance) Then
         Condition = True
        Condition = (Fst.Left > Snd.Left)
      End If
      If Condition = True Then
         Set Temp = BoxInfos(i + 1)
         Set BoxInfos(i + 1) = BoxInfos(i)
         Set BoxInfos(i) = Temp
         Sorted = False
      End If
End Function

Function Millimeter to Pixel

Private Function MMToPixel(DocumentResolution As Double, MM As Double) As Double
   MMToPixel = MM / 25.4 * DocumentResolution
End Function

Function Pixel to Millimeter

Private Function PixelToMM(DocumentResolution As Double, Pixel As Double) As Double
  PixelToMM = (25.4 * Pixel) / DocumentResolution
End Function


Level of Complexity 



Applies to  

Product Version Build Environment Hardware
Kofax Transformation Module  all      



Article # 3035590
  • Was this article helpful?