Leadtools.Document Deprecated as of v16. Refer to: Leadtools.Forms.Ocr | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
AddZone Method
See Also  Example
Leadtools.Document Namespace > RasterDocumentEngine Class : AddZone Method



pageIndex
Index of the page on which to add the zone. This is a zero-based index.
zoneIndex
Position in the list of zones at which to add the new zone. Use -1 to append the page to the end of the list. This is a zero-based index.
zoneData
RasterDocumentZoneData class that contains the zone data to be added.
pageIndex
Index of the page on which to add the zone. This is a zero-based index.
zoneIndex
Position in the list of zones at which to add the new zone. Use -1 to append the page to the end of the list. This is a zero-based index.
zoneData
RasterDocumentZoneData class that contains the zone data to be added.
Adds a new zone to the zone list of the specified page.

Syntax

Visual Basic (Declaration) 
Public Sub AddZone( _
   ByVal pageIndex As Integer, _
   ByVal zoneIndex As Integer, _
   ByVal zoneData As RasterDocumentZoneData _
) 
Visual Basic (Usage)Copy Code
Dim instance As RasterDocumentEngine
Dim pageIndex As Integer
Dim zoneIndex As Integer
Dim zoneData As RasterDocumentZoneData
 
instance.AddZone(pageIndex, zoneIndex, zoneData)
C# 
public void AddZone( 
   int pageIndex,
   int zoneIndex,
   RasterDocumentZoneData zoneData
)
C++/CLI 
public:
void AddZone( 
   int pageIndex,
   int zoneIndex,
   RasterDocumentZoneData^ zoneData
) 

Parameters

pageIndex
Index of the page on which to add the zone. This is a zero-based index.
zoneIndex
Position in the list of zones at which to add the new zone. Use -1 to append the page to the end of the list. This is a zero-based index.
zoneData
RasterDocumentZoneData class that contains the zone data to be added.

Example

Visual BasicCopy Code
Public Sub AddZoneExample()
   Dim buffer As String

   ' Note that this is a sample key, which will not work in your toolkit
   RasterSupport.Unlock(Leadtools.RasterSupportType.Ocr, "TestKey")

   Dim rasterDocument As RasterDocumentEngine
   rasterDocument = RasterDocumentEngine.Instance
   rasterDocument.Startup()
   'assume page is added, refer to AddPage example for more information

   Dim zoneData As RasterDocumentZoneData = New RasterDocumentZoneData()

   zoneData.Rectangle = New Rectangle(100, 100, 100, 100)
   zoneData.FillMethod = RasterDocumentFillMethod.Default
   zoneData.RecognizeModule = RasterDocumentRecognizeModule.Auto
   zoneData.CharacterFilter = RasterDocumentCharacterFilter.Default
   zoneData.Type = RasterDocumentZoneType.FlowText
   zoneData.Flags = RasterDocumentZoneFlags.None
   zoneData.SectionName = "cities"

   Try
      rasterDocument.AddZone(0, 0, zoneData)
      buffer = String.Format("The engine added a new zone to the document successfully" & Constants.vbLf & "The Added Zone ID = {0}", zoneData.Id)

      MessageBox.Show(buffer)
   Catch ex As Exception
      MessageBox.Show(ex.Message)
   End Try

   Dim zoneCount As Integer = rasterDocument.GetZoneCount(0)
   buffer = String.Format("Total zones in the specified page: {0}" & zoneCount)
   MessageBox.Show(buffer)
   rasterDocument.Shutdown()
End Sub
C#Copy Code
public void AddZoneExample() 

   string buffer; 
   // Note that this is a sample key, which will not work in your toolkit 
   RasterSupport.Unlock(Leadtools.RasterSupportType.Ocr, "TestKey"); 
   RasterDocumentEngine rasterDocument; 
   rasterDocument = RasterDocumentEngine.Instance; 
   rasterDocument.Startup(); 
 
   // assume page is added, refer to AddPage example for more information 
 
   RasterDocumentZoneData zoneData = new RasterDocumentZoneData(); 
 
   zoneData.Rectangle = new Rectangle(100, 100, 100, 100); 
   zoneData.FillMethod = RasterDocumentFillMethod.Default; 
   zoneData.RecognizeModule = RasterDocumentRecognizeModule.Auto; 
   zoneData.CharacterFilter = RasterDocumentCharacterFilter.Default; 
   zoneData.Type = RasterDocumentZoneType.FlowText; 
   zoneData.Flags = RasterDocumentZoneFlags.None; 
   zoneData.SectionName = "cities"; 
 
   try 
   { 
      rasterDocument.AddZone(0, 0, zoneData); 
      buffer = string.Format("The engine added a new zone to the document successfully\nThe Added Zone ID = {0}", zoneData.Id); 
 
      MessageBox.Show(buffer); 
   } 
   catch (Exception ex) 
   { 
      MessageBox.Show(ex.Message); 
   } 
 
   int zoneCount = rasterDocument.GetZoneCount(0); 
   buffer = string.Format("Total zones in the specified page: {0}" + zoneCount); 
   MessageBox.Show(buffer); 
   rasterDocument.Shutdown(); 
}

Remarks

Adds a new zone to the zone list of the specified page. After the zone is added, the zone list is recalculated automatically. When adding a zone, the application should directly initialize the following properties of the RasterDocumentZoneData class, since these members will not take their default values: The OCR engine manages the RasterDocumentZoneData.Id property. The RasterDocumentZoneData.Type property should be one of the following values: For successful zone addition, the whole zone area must lie within the page area and the top left coordinates of the zone must have lower values than those of the bottom right ones. To find all zones in a specific page, use FindZones.
For more information, refer to Working with Zones.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also

The Leadtools.Document namespace is deprecated and no longer supported as of LEADTOOLS v16. For v16 and later, please refer to: Leadtools.Forms.Ocr. This documentation is retained for v15 and earlier informational use only.