LEADTOOLS OCR (Leadtools.Forms.Ocr assembly)
LEAD Technologies, Inc

IOcrTableZoneManager Interface

Example 





Members 
Represents an Object used to manipulate cells inside a table zone. .NET support
Object Model
IOcrTableZoneManager Interface
Syntax
public interface IOcrTableZoneManager 
'Declaration
 
Public Interface IOcrTableZoneManager 
'Usage
 
Dim instance As IOcrTableZoneManager
public interface IOcrTableZoneManager 
function Leadtools.Forms.Ocr.IOcrTableZoneManager() 
public interface class IOcrTableZoneManager 
Remarks

You can access the IOcrTableZoneManager of an OCR page through the IOcrPage.TableZoneManager property. If the value of this property is null (Nothing in Visual Basic), then the current OCR engine does not support table cell manipulation.

You can use table cells in one of two ways:

To manipulate a cell properties other than its bound (OcrZoneCell.Bounds), get the array of detected cells through OcrZone.Cells, change the cell background color, style or any border color, style or with. When you are done, re-set the array to OcrZone.Cells and call IOcrTableZoneManager.UpdateCells.

It is not recommended that you manually remove or add cells to the OcrZone.Cells, the engine is very sensitive to zone boundaries and any non-accurate information will cause an error. Instead, use the various methods of IOcrTableZoneManager to manipulate the cell location and size.

Manipulating cells position and size inside a table zone is a very sensitive matter and any non-accurate information will cause an error. The IOcrTableZoneManager contains methods to easily accomplish these tasks with minimum error. These methods are built around what is expected to be accomplished by an application that manipulates the cells of a zone through a user-interface, such as clicking and dragging with the mouse.

The following methods can be used to manipulate the cells position and size:

Example
Copy CodeCopy Code  
Private Shared Sub IOcrTableZoneManageExample(ByVal ocrEngine As IOcrEngine, ByVal documentFileName As String)
   ' Create a document and add the page to it
   Using ocrDocument As IOcrDocument = ocrEngine.DocumentManager.CreateDocument()
      Dim ocrPage As IOcrPage = ocrDocument.Pages.AddPage(documentFileName, Nothing)
      ' The coordinate for the table has been previously determined:
      Dim tableBounds As New LogicalRectangle(266, 554, 404, 647, LogicalUnit.Pixel)

      ' Add a table zone with these bounds
      Dim zone As New OcrZone()
      zone.ZoneType = OcrZoneType.Table
      zone.Bounds = tableBounds
      ocrPage.Zones.Add(zone)

      ' Detect the cells inside this table
      Dim ocrTableZoneManager As IOcrTableZoneManager = ocrPage.TableZoneManager
      ocrTableZoneManager.AutoDetectCells(0)

      ' Show the cells for this zone (if any)
      zone = ocrPage.Zones(0)

      Console.WriteLine("Detected values:")
      ShowCells(zone)

      ' Change the style of the first cell to have no borders
      If Not IsNothing(zone.Cells) AndAlso zone.Cells.Length > 0 Then
         Dim cell As OcrZoneCell = zone.Cells(0)
         cell.LeftBorderStyle = OcrCellBorderLineStyle.None
         cell.TopBorderStyle = OcrCellBorderLineStyle.None
         cell.RightBorderStyle = OcrCellBorderLineStyle.None
         cell.BottomBorderStyle = OcrCellBorderLineStyle.None
         zone.Cells(0) = cell

         ocrPage.Zones(0) = zone
         zone = ocrPage.Zones(0)

         Console.WriteLine("Updated values:")
         ShowCells(zone)
      End If
   End Using
End Sub

Private Shared Sub ShowCells(ByVal zone As OcrZone)
   If Not IsNothing(zone.Cells) Then
      Console.WriteLine("Table contains {0} zones", zone.Cells.Length)

      For i As Integer = 0 To zone.Cells.Length - 1
         Console.WriteLine("  Cell {0}:", i)

         Dim cell As OcrZoneCell = zone.Cells(i)
         Console.WriteLine("    Type: {0}", cell.CellType)
         Console.WriteLine("    Bounds: {0}", cell.Bounds)
         Console.WriteLine("    Background color: {0}", cell.BackgroundColor)
         Console.WriteLine("    Left border color: {0}", cell.LeftBorderColor)
         Console.WriteLine("    Left border width: {0}", cell.LeftBorderWidth)
         Console.WriteLine("    Left border style: {0}", cell.LeftBorderStyle)
         Console.WriteLine("    Top border color: {0}", cell.TopBorderColor)
         Console.WriteLine("    Top border width: {0}", cell.TopBorderWidth)
         Console.WriteLine("    Top border style: {0}", cell.TopBorderStyle)
         Console.WriteLine("    Right border color: {0}", cell.RightBorderColor)
         Console.WriteLine("    Right border width: {0}", cell.RightBorderWidth)
         Console.WriteLine("    Right border style: {0}", cell.RightBorderStyle)
         Console.WriteLine("    Bottom border color: {0}", cell.BottomBorderColor)
         Console.WriteLine("    Bottom border width: {0}", cell.BottomBorderWidth)
         Console.WriteLine("    Bottom border style: {0}", cell.BottomBorderStyle)
      Next
   End If
End Sub
private static void IOcrTableZoneManageExample(IOcrEngine ocrEngine, string documentFileName)
{
   // Create a document and add the page to it
   using(IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument())
   {
      IOcrPage ocrPage = ocrDocument.Pages.AddPage(documentFileName, null);
      // The coordinate for the table has been previously determined:
      LogicalRectangle tableBounds = new LogicalRectangle(266, 554, 404, 647, LogicalUnit.Pixel);

      // Add a table zone with these bounds
      OcrZone zone = new OcrZone();
      zone.ZoneType = OcrZoneType.Table;
      zone.Bounds = tableBounds;
      ocrPage.Zones.Add(zone);

      // Detect the cells inside this table
      IOcrTableZoneManager ocrTableZoneManager = ocrPage.TableZoneManager;
      ocrTableZoneManager.AutoDetectCells(0);

      // Show the cells for this zone (if any)
      zone = ocrPage.Zones[0];

      Console.WriteLine("Detected values:");
      ShowCells(zone);

      // Change the style of the first cell to have no borders
      if(zone.Cells != null && zone.Cells.Length > 0)
      {
         OcrZoneCell cell = zone.Cells[0];
         cell.LeftBorderStyle = OcrCellBorderLineStyle.None;
         cell.TopBorderStyle = OcrCellBorderLineStyle.None;
         cell.RightBorderStyle = OcrCellBorderLineStyle.None;
         cell.BottomBorderStyle = OcrCellBorderLineStyle.None;
         zone.Cells[0] = cell;

         ocrPage.Zones[0] = zone;
         zone = ocrPage.Zones[0];

         Console.WriteLine("Updated values:");
         ShowCells(zone);
      }
   }
}

private static void ShowCells(OcrZone zone)
{
   if(zone.Cells != null)
   {
      Console.WriteLine("Table contains {0} zones", zone.Cells.Length);

      for(int i = 0; i < zone.Cells.Length; i++)
      {
         Console.WriteLine("  Cell {0}:", i);

         OcrZoneCell cell = zone.Cells[i];
         Console.WriteLine("    Type: {0}", cell.CellType);
         Console.WriteLine("    Bounds: {0}", cell.Bounds);
         Console.WriteLine("    Background color: {0}", cell.BackgroundColor);
         Console.WriteLine("    Left border color: {0}", cell.LeftBorderColor);
         Console.WriteLine("    Left border width: {0}", cell.LeftBorderWidth);
         Console.WriteLine("    Left border style: {0}", cell.LeftBorderStyle);
         Console.WriteLine("    Top border color: {0}", cell.TopBorderColor);
         Console.WriteLine("    Top border width: {0}", cell.TopBorderWidth);
         Console.WriteLine("    Top border style: {0}", cell.TopBorderStyle);
         Console.WriteLine("    Right border color: {0}", cell.RightBorderColor);
         Console.WriteLine("    Right border width: {0}", cell.RightBorderWidth);
         Console.WriteLine("    Right border style: {0}", cell.RightBorderStyle);
         Console.WriteLine("    Bottom border color: {0}", cell.BottomBorderColor);
         Console.WriteLine("    Bottom border width: {0}", cell.BottomBorderWidth);
         Console.WriteLine("    Bottom border style: {0}", cell.BottomBorderStyle);
      }
   }
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

IOcrTableZoneManager Members
Leadtools.Forms.Ocr Namespace

Represents an Object used to manipulate cells inside a table zone. .NET support
Object Model
IOcrTableZoneManager Interface
Syntax
public interface IOcrTableZoneManager 
'Declaration
 
Public Interface IOcrTableZoneManager 
'Usage
 
Dim instance As IOcrTableZoneManager
public interface IOcrTableZoneManager 
function Leadtools.Forms.Ocr.IOcrTableZoneManager() 
public interface class IOcrTableZoneManager 
Remarks

You can access the IOcrTableZoneManager of an OCR page through the IOcrPage.TableZoneManager property. If the value of this property is null (Nothing in Visual Basic), then the current OCR engine does not support table cell manipulation.

You can use table cells in one of two ways:

To manipulate a cell properties other than its bound (OcrZoneCell.Bounds), get the array of detected cells through OcrZone.Cells, change the cell background color, style or any border color, style or with. When you are done, re-set the array to OcrZone.Cells and call IOcrTableZoneManager.UpdateCells.

It is not recommended that you manually remove or add cells to the OcrZone.Cells, the engine is very sensitive to zone boundaries and any non-accurate information will cause an error. Instead, use the various methods of IOcrTableZoneManager to manipulate the cell location and size.

Manipulating cells position and size inside a table zone is a very sensitive matter and any non-accurate information will cause an error. The IOcrTableZoneManager contains methods to easily accomplish these tasks with minimum error. These methods are built around what is expected to be accomplished by an application that manipulates the cells of a zone through a user-interface, such as clicking and dragging with the mouse.

The following methods can be used to manipulate the cells position and size:

Example
Copy CodeCopy Code  
Private Shared Sub IOcrTableZoneManageExample(ByVal ocrEngine As IOcrEngine, ByVal documentFileName As String)
   ' Create a document and add the page to it
   Using ocrDocument As IOcrDocument = ocrEngine.DocumentManager.CreateDocument()
      Dim ocrPage As IOcrPage = ocrDocument.Pages.AddPage(documentFileName, Nothing)
      ' The coordinate for the table has been previously determined:
      Dim tableBounds As New LogicalRectangle(266, 554, 404, 647, LogicalUnit.Pixel)

      ' Add a table zone with these bounds
      Dim zone As New OcrZone()
      zone.ZoneType = OcrZoneType.Table
      zone.Bounds = tableBounds
      ocrPage.Zones.Add(zone)

      ' Detect the cells inside this table
      Dim ocrTableZoneManager As IOcrTableZoneManager = ocrPage.TableZoneManager
      ocrTableZoneManager.AutoDetectCells(0)

      ' Show the cells for this zone (if any)
      zone = ocrPage.Zones(0)

      Console.WriteLine("Detected values:")
      ShowCells(zone)

      ' Change the style of the first cell to have no borders
      If Not IsNothing(zone.Cells) AndAlso zone.Cells.Length > 0 Then
         Dim cell As OcrZoneCell = zone.Cells(0)
         cell.LeftBorderStyle = OcrCellBorderLineStyle.None
         cell.TopBorderStyle = OcrCellBorderLineStyle.None
         cell.RightBorderStyle = OcrCellBorderLineStyle.None
         cell.BottomBorderStyle = OcrCellBorderLineStyle.None
         zone.Cells(0) = cell

         ocrPage.Zones(0) = zone
         zone = ocrPage.Zones(0)

         Console.WriteLine("Updated values:")
         ShowCells(zone)
      End If
   End Using
End Sub

Private Shared Sub ShowCells(ByVal zone As OcrZone)
   If Not IsNothing(zone.Cells) Then
      Console.WriteLine("Table contains {0} zones", zone.Cells.Length)

      For i As Integer = 0 To zone.Cells.Length - 1
         Console.WriteLine("  Cell {0}:", i)

         Dim cell As OcrZoneCell = zone.Cells(i)
         Console.WriteLine("    Type: {0}", cell.CellType)
         Console.WriteLine("    Bounds: {0}", cell.Bounds)
         Console.WriteLine("    Background color: {0}", cell.BackgroundColor)
         Console.WriteLine("    Left border color: {0}", cell.LeftBorderColor)
         Console.WriteLine("    Left border width: {0}", cell.LeftBorderWidth)
         Console.WriteLine("    Left border style: {0}", cell.LeftBorderStyle)
         Console.WriteLine("    Top border color: {0}", cell.TopBorderColor)
         Console.WriteLine("    Top border width: {0}", cell.TopBorderWidth)
         Console.WriteLine("    Top border style: {0}", cell.TopBorderStyle)
         Console.WriteLine("    Right border color: {0}", cell.RightBorderColor)
         Console.WriteLine("    Right border width: {0}", cell.RightBorderWidth)
         Console.WriteLine("    Right border style: {0}", cell.RightBorderStyle)
         Console.WriteLine("    Bottom border color: {0}", cell.BottomBorderColor)
         Console.WriteLine("    Bottom border width: {0}", cell.BottomBorderWidth)
         Console.WriteLine("    Bottom border style: {0}", cell.BottomBorderStyle)
      Next
   End If
End Sub
private static void IOcrTableZoneManageExample(IOcrEngine ocrEngine, string documentFileName)
{
   // Create a document and add the page to it
   using(IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument())
   {
      IOcrPage ocrPage = ocrDocument.Pages.AddPage(documentFileName, null);
      // The coordinate for the table has been previously determined:
      LogicalRectangle tableBounds = new LogicalRectangle(266, 554, 404, 647, LogicalUnit.Pixel);

      // Add a table zone with these bounds
      OcrZone zone = new OcrZone();
      zone.ZoneType = OcrZoneType.Table;
      zone.Bounds = tableBounds;
      ocrPage.Zones.Add(zone);

      // Detect the cells inside this table
      IOcrTableZoneManager ocrTableZoneManager = ocrPage.TableZoneManager;
      ocrTableZoneManager.AutoDetectCells(0);

      // Show the cells for this zone (if any)
      zone = ocrPage.Zones[0];

      Console.WriteLine("Detected values:");
      ShowCells(zone);

      // Change the style of the first cell to have no borders
      if(zone.Cells != null && zone.Cells.Length > 0)
      {
         OcrZoneCell cell = zone.Cells[0];
         cell.LeftBorderStyle = OcrCellBorderLineStyle.None;
         cell.TopBorderStyle = OcrCellBorderLineStyle.None;
         cell.RightBorderStyle = OcrCellBorderLineStyle.None;
         cell.BottomBorderStyle = OcrCellBorderLineStyle.None;
         zone.Cells[0] = cell;

         ocrPage.Zones[0] = zone;
         zone = ocrPage.Zones[0];

         Console.WriteLine("Updated values:");
         ShowCells(zone);
      }
   }
}

private static void ShowCells(OcrZone zone)
{
   if(zone.Cells != null)
   {
      Console.WriteLine("Table contains {0} zones", zone.Cells.Length);

      for(int i = 0; i < zone.Cells.Length; i++)
      {
         Console.WriteLine("  Cell {0}:", i);

         OcrZoneCell cell = zone.Cells[i];
         Console.WriteLine("    Type: {0}", cell.CellType);
         Console.WriteLine("    Bounds: {0}", cell.Bounds);
         Console.WriteLine("    Background color: {0}", cell.BackgroundColor);
         Console.WriteLine("    Left border color: {0}", cell.LeftBorderColor);
         Console.WriteLine("    Left border width: {0}", cell.LeftBorderWidth);
         Console.WriteLine("    Left border style: {0}", cell.LeftBorderStyle);
         Console.WriteLine("    Top border color: {0}", cell.TopBorderColor);
         Console.WriteLine("    Top border width: {0}", cell.TopBorderWidth);
         Console.WriteLine("    Top border style: {0}", cell.TopBorderStyle);
         Console.WriteLine("    Right border color: {0}", cell.RightBorderColor);
         Console.WriteLine("    Right border width: {0}", cell.RightBorderWidth);
         Console.WriteLine("    Right border style: {0}", cell.RightBorderStyle);
         Console.WriteLine("    Bottom border color: {0}", cell.BottomBorderColor);
         Console.WriteLine("    Bottom border width: {0}", cell.BottomBorderWidth);
         Console.WriteLine("    Bottom border style: {0}", cell.BottomBorderStyle);
      }
   }
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

IOcrTableZoneManager Members
Leadtools.Forms.Ocr Namespace

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

IOcrTableZoneManager requires an OCR module license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features