←Select platform

PagesZones Property

Summary

Gets or sets the object that holds the user zones for the pages to be recognized.

Syntax

C#
VB
C++
[DataMemberAttribute(Name="PagesZones", IsRequired=false)] 
public OcrPagesZones PagesZones { get; set; } 
  
<DataMemberAttribute("PagesZones")> 
Public Property PagesZones As Leadtools.Services.Forms.Datacontracts.OcrPagesZones 
[DataMemberAttribute("PagesZones")] 
public: 
property Leadtools.Services.Forms.Datacontracts.OcrPagesZones^ PagesZones { 
   Leadtools.Services.Forms.Datacontracts.OcrPagesZones^ get(); 
   void set (    Leadtools.Services.Forms.Datacontracts.OcrPagesZones^ ); 
} 

Property Value

An OcrPagesZones object that holds the user zones for the pages to be recognized. Default value is null (Nothing in VB).

Remarks

When the value of this property is the default of null (Nothing in VB), the service will perform auto-zoning on each page in the source document.

If you have pre-defined zones, then create an object of type OcrPagesZones and put it in the PagesZones property. Add the zones to the OcrPageZones.Zones list and set the OcrPageZones.PageNumber value to the page associated with this zone in the source document. The service will load the zones for each page from this list and add them directly to the page before recognition and skips the auto-zoning process.

If the OcrPageZones entry for a specific page is null (Nothing in VB) or does not contains any OcrZone items, then auto-zoning is performed on this page.

Example

This example will perform show how to use your own pre-defined zones in the recognition process.

C#
VB
using Leadtools.Services; 
using Leadtools.Services.Forms.ServiceContracts; 
using Leadtools.Services.Forms.ServiceImplementations; 
//using Leadtools.Services.Forms.DataContractsExamples.localhost; 
 
private static void OcrWithZonesExample() 
{ 
   using (OcrServiceClient client = new OcrServiceClient()) 
   { 
      // Setup the source and destination documents 
      FileBinaryData srcData = new FileBinaryData(); 
      srcData.FileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif"); 
 
      FileBinaryData destData = new FileBinaryData(); 
      destData.FileName = Path.Combine(LEAD_VARS.ImagesDir, "OcrService.pdf"); 
 
      if (System.IO.File.Exists(destData.FileName)) 
      { 
         System.IO.File.Delete(destData.FileName); 
      } 
 
      // Setup the convert options 
      DocumentConvertOptions options = new DocumentConvertOptions(); 
      options.FirstPageNumber = 1; 
      options.LastPageNumber = 1; 
      options.Source = srcData; 
      options.Destination = destData; 
      options.Format = OcrDocumentFormatType.Pdf; 
 
      // One text and one graphics zones 
      options.PagesZones = new OcrPagesZones(); 
 
      OcrPageZones pageZones = new OcrPageZones(); 
      pageZones.PageNumber = 1; 
      pageZones.Zones = new OcrZones(); 
 
      OcrZone zone; 
      LeadRect bounds; 
 
      zone = new OcrZone(); 
      zone.ZoneType = OcrZoneType.Text; 
      bounds = new LeadRect(); 
      bounds.X = 337; 
      bounds.Y = 323; 
      bounds.Width = 1944; 
      bounds.Height = 264; 
      zone.Bounds = bounds; 
      pageZones.Zones.Add(zone); 
 
      zone = new OcrZone(); 
      zone.ZoneType = OcrZoneType.Graphic; 
      bounds = new LeadRect(); 
      bounds.X = 322; 
      bounds.Y = 1320; 
      bounds.Width = 2053; 
      bounds.Height = 326; 
      zone.Bounds = bounds; 
      pageZones.Zones.Add(zone); 
 
      options.PagesZones.Add(pageZones); 
 
      // Recognize 
      RecognizeRequest request = new RecognizeRequest(); 
      request.ConvertOptions = options; 
 
      client.Recognize(request); 
 
      System.Diagnostics.Process.Start(destData.FileName); 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; 
} 
Imports Leadtools.Services 
Imports Leadtools.Services.Forms.ServiceContracts 
Imports Leadtools.Services.Forms.ServiceImplementations 
'using Leadtools.Services.Forms.DataContractsExamples.localhost; 
 
Private Shared Sub OcrWithZonesExample() 
   Using client As New OcrServiceClient() 
      ' Setup the source and destination documents 
      Dim srcData As New FileBinaryData() 
      srcData.FileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif") 
 
      Dim destData As New FileBinaryData() 
      destData.FileName = Path.Combine(LEAD_VARS.ImagesDir, "OcrService.pdf") 
 
      If System.IO.File.Exists(destData.FileName) Then 
         System.IO.File.Delete(destData.FileName) 
      End If 
 
      ' Setup the convert options 
      Dim options As New DocumentConvertOptions() 
      options.FirstPageNumber = 1 
      options.LastPageNumber = 1 
      options.Source = srcData 
      options.Destination = destData 
      options.Format = OcrDocumentFormatType.Pdf 
 
      ' One text and one graphics zones 
      options.PagesZones = New OcrPagesZones() 
 
      Dim pageZones As New OcrPageZones() 
      pageZones.PageNumber = 1 
      pageZones.Zones = New OcrZones() 
 
      Dim zone As OcrZone 
      Dim bounds As LeadRect 
 
      zone = New OcrZone() 
      zone.ZoneType = OcrZoneType.Text 
      bounds = New LeadRect() 
      bounds.X = 337 
      bounds.Y = 323 
      bounds.Width = 1944 
      bounds.Height = 264 
      zone.Bounds = bounds 
      pageZones.Zones.Add(zone) 
 
      zone = New OcrZone() 
      zone.ZoneType = OcrZoneType.Graphic 
      bounds = New LeadRect() 
      bounds.X = 322 
      bounds.Y = 1320 
      bounds.Width = 2053 
      bounds.Height = 326 
      zone.Bounds = bounds 
      pageZones.Zones.Add(zone) 
 
      options.PagesZones.Add(pageZones) 
 
      ' Recognize 
      Dim request As New RecognizeRequest() 
      request.ConvertOptions = options 
 
      client.Recognize(request) 
 
      System.Diagnostics.Process.Start(destData.FileName) 
   End Using 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" 
End Class 

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.