Represents the exception that is thrown when a support locked runtime error occurs inside the IOcrEngine.
[SerializableAttribute()]public class OcrSupportLockedException : Exception
<SerializableAttribute()>Public Class OcrSupportLockedExceptionInherits System.ExceptionImplements System.Runtime.InteropServices._Exception, System.Runtime.Serialization.ISerializable
public class OcrSupportLockedException extends RuntimeException [SerializableAttribute()]public ref class OcrSupportLockedException : public System.Exception, System.Runtime.InteropServices._Exception, System.Runtime.Serialization.ISerializable
Various parts of the LEADTOOLS OCR toolkit are locked by a specific key. If these features are used without first unlocking the specified feature, an exception of type OcrSupportLockedException will be thrown. Examine the OcrSupportLockedException.SupportType property to determine which unlock support feature is required.
For a description of the support types, refer to OcrSupportLockedExceptionType.
For more information on feature support and how to obtain the unlock keys, refer to Unlocking Special LEAD Features, RasterSupport and RasterSupportType.
This example shows how to trap various types of exceptions during OCR operations.
using Leadtools;using Leadtools.Codecs;using Leadtools.Ocr;using Leadtools.Document.Writer;public void OcrExceptionExample(){try{// Create an instance of the engineusing (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, false)){// Start the engine using default parametersocrEngine.Startup(null, null, null, LEAD_VARS.OcrLEADRuntimeDir);string tifFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif");string pdfFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.pdf");// Create a page// Create an OCR documentusing (IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument()){// Add a page to the documentIOcrPage ocrPage = ocrDocument.Pages.AddPage(tifFileName, null);// Recognize the page// Note, Recognize can be called without calling AutoZone or manually adding zones. The engine will// check and automatically auto-zones the pageocrPage.Recognize(null);// Save the document we have as PDFocrDocument.Save(pdfFileName, DocumentFormat.Pdf, null);}// Shutdown the engine// Note: calling Dispose will also automatically shutdown the engine if it has been startedocrEngine.Shutdown();}}catch (OcrSupportLockedException ex){Console.WriteLine("Support is locked. You need to unlock '{0}' in this engine to use this feature", ex.SupportType);}catch (OcrException ex){Console.WriteLine("OCR Error\nCode: {0}\nMessage:{1}", ex.Code, ex.Message);}catch (RasterException ex){Console.WriteLine("LEADTOOLS Error\nCode: {0}\nMessage:{1}", ex.Code, ex.Message);}catch (Exception ex){Console.WriteLine("System Error\nMessage:{0}", ex.Message);}}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS 20\Bin\Common\OcrLEADRuntime";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.OcrImports Leadtools.Document.WriterPublic Sub OcrExceptionExample()Try' Create an instance of the engineUsing ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, False)' Start the engine using default parametersocrEngine.Startup(Nothing, Nothing, Nothing, LEAD_VARS.OcrLEADRuntimeDir)Dim tifFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif")Dim pdfFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.pdf")' Create a page' Create an OCR documentUsing ocrDocument As IOcrDocument = ocrEngine.DocumentManager.CreateDocument()' Add a page to the documentDim ocrPage As IOcrPage = ocrDocument.Pages.AddPage(tifFileName, Nothing)' Recognize the page' Note, Recognize can be called without calling AutoZone or manually adding zones. The engine will' check and automatically auto-zones the pageocrPage.Recognize(Nothing)' Save the document we have as PDFocrDocument.Save(pdfFileName, DocumentFormat.Pdf, Nothing)End Using' Shutdown the engine' Note: calling Dispose will also automatically shutdown the engine if it has been startedocrEngine.Shutdown()End UsingCatch ex As OcrSupportLockedExceptionConsole.WriteLine("Support is locked. You need to unlock '{0}' in this engine to use this feature", ex.SupportType)Catch ex As OcrExceptionConsole.WriteLine("OCR Error" & vbLf & "Code: {0}" & vbLf & "Message:{1}", ex.Code, ex.Message)Catch ex As RasterExceptionConsole.WriteLine("LEADTOOLS Error" & vbLf & "Code: {0}" & vbLf & "Message:{1}", ex.Code, ex.Message)Catch ex As ExceptionConsole.WriteLine("System Error" & vbLf & "Message:{0}", ex.Message)End TryEnd SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"Public Const OcrLEADRuntimeDir As String = "C:\LEADTOOLS 20\Bin\Common\OcrLEADRuntime"End Class
OcrSupportLockedException Members
OcrSupportLockedExceptionType Enumeration
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
