LEADTOOLS WCF OCR (Leadtools.Services.Forms.DataContracts assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.31
PagesZones Property
See Also 
Leadtools.Services.Forms.DataContracts Namespace > DocumentConvertOptions Structure : PagesZones Property



The PagesZones Property is available in LEADTOOLS Document and Medical Imaging toolkits.

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

Syntax

Visual Basic (Declaration) 
<DataMemberAttribute("PagesZones")>
Public Property PagesZones As OcrPagesZones
Visual Basic (Usage)Copy Code
Dim instance As DocumentConvertOptions
Dim value As OcrPagesZones
 
instance.PagesZones = value
 
value = instance.PagesZones
C# 
[DataMemberAttribute("PagesZones")]
public OcrPagesZones PagesZones {get; set;}
C++/CLI 
[DataMemberAttribute("PagesZones")]
public:
property OcrPagesZones^ PagesZones {
   OcrPagesZones^ get();
   void set (    OcrPagesZones^ value);
}

Property Value

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

Example

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

Visual BasicCopy Code
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
C#Copy Code
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";
}

Remarks

When the value of this property is the default of null (Nothing in Visual Basic), 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 Visual Basic) or does not contains any OcrZone items, then auto-zoning is performed on this page.

Requirements

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

See Also

Applications developed with LEADTOOLS WCF components require runtime licenses. Server licensing is required for applications on a server. For more information, refer to: Imaging Pro/Document/Medical Features