LEADTOOLS Support
Document
Document SDK Examples
How to remove Graphic zone types from a PDF while using LEADTOOLS OCR
Groups: Registered
Posts: 119
Was thanked: 4 time(s) in 4 post(s)
There are multiple
Ocr Zone Types that can be found when the LEADTOOLS OCR engine calls
AutoZone to detect all the zones on a document. Sometimes the zoning may detect more zones than you would like to recognize.
Below you will find code that will demonstrate how to remove a graphic zone from the collection of zone types that have been found as well as Save the zones found, print out the bounds of the zones (x,y), recognize the document and save the text output as a text file.
Code:
using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false))
{
ocrEngine.Startup(null, null, null, @"C:\LEADTOOLS 19\Bin\Common\OcrAdvantageRuntime");
using (IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument())
{
RasterImage image = ocrEngine.RasterCodecsInstance.Load(input, 0, CodecsLoadByteOrder.Rgb, 1, -1);
IOcrPage ocrPage = ocrDocument.Pages.AddPage(image, null);
ocrPage.AutoZone(null);
foreach (OcrZone zone in ocrPage.Zones)
{
if (zone.ZoneType == OcrZoneType.Graphic)
{
ocrPage.Zones.Remove(zone);
break;
}
}
ocrPage.SaveZones(@"SAVE LOCATION.ozf");
foreach (OcrZone ocrZone in ocrPage.Zones)
{
int index = ocrPage.Zones.IndexOf(ocrZone);
Console.WriteLine("Zone index: {0}", index);
Console.WriteLine(" Id {0}", ocrZone.Id);
Console.WriteLine(" Bounds {0}", ocrZone.Bounds);
Console.WriteLine(" ZoneType {0}", ocrZone.ZoneType);
Console.WriteLine("----------------------------------");
}
ocrDocument.Pages.Recognize(null);
ocrDocument.Save(output, DocumentFormat.Text, null);
}
ocrEngine.Shutdown();
}
Nick Villalobos
Developer Support Engineer
LEAD Technologies, Inc.

LEADTOOLS Support
Document
Document SDK Examples
How to remove Graphic zone types from a PDF while using LEADTOOLS OCR
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.