Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.5.10
|
Leadtools.Services.Forms.DataContracts Namespace > DocumentConvertOptions Structure : PagesZones Property |
[DataMemberAttribute("PagesZones")] public OcrPagesZones PagesZones {get; set;}
'Declaration <DataMemberAttribute("PagesZones")> Public Property PagesZones As OcrPagesZones
'Usage Dim instance As DocumentConvertOptions Dim value As OcrPagesZones instance.PagesZones = value value = instance.PagesZones
[DataMemberAttribute("PagesZones")] public: property OcrPagesZones^ PagesZones { OcrPagesZones^ get(); void set ( OcrPagesZones^ value); }
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.
This example will perform show how to use your own pre-defined zones in the recognition process.
Imports Leadtools.Services Imports Leadtools.Services.Forms.ServiceContracts Imports Leadtools.Services.Forms.ServiceImplementations Imports leadtools.services.forms.datacontracts._2009._01 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
using Leadtools.Services; using Leadtools.Services.Forms.ServiceContracts; using Leadtools.Services.Forms.ServiceImplementations; using leadtools.services.forms.datacontracts._2009._01; 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"; }