PagesZones Property
Summary
Gets or sets the object that holds the user zones for the pages to be recognized.
Syntax
[DataMemberAttribute(Name="PagesZones", IsRequired=false)]
public OcrPagesZones PagesZones { get; set; }
Property Value
An OcrPagesZones object that holds the user zones for the pages to be recognized. Default value is null (Nothing in VB).
Example
This example will perform show how to use your own pre-defined zones in the recognition process.
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