Error processing SSI file
LEADTOOLS OCR (Leadtools.Forms.Ocr assembly)

Show in webframe

OcrSupportLockedException Class








Members 
Represents the exception that is thrown when a support locked runtime error occurs inside the IOcrEngine.
Object Model
Syntax
'Declaration
 
<SerializableAttribute()>
Public Class OcrSupportLockedException 
   Inherits System.Exception
   Implements System.Runtime.InteropServices._Exception, System.Runtime.Serialization.ISerializable 
'Usage
 
Dim instance As OcrSupportLockedException
public sealed class OcrSupportLockedException : System.Runtime.InteropServices._Exception, ~Remove~  
public class OcrSupportLockedException extends RuntimeException
function Leadtools.Forms.Ocr.OcrSupportLockedException()
Remarks

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.

Example

This example shows how to trap various types of exceptions during OCR operations.

Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Forms.Ocr
Imports Leadtools.Forms.DocumentWriters

<TestMethod>
Public Sub OcrExceptionExample()
   Try
      ' Create an instance of the engine
      Using ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, False)
         ' Start the engine using default parameters
         ocrEngine.Startup(Nothing, Nothing, Nothing, LEAD_VARS.OcrAdvantageRuntimeDir)
         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 document
         Using ocrDocument As IOcrDocument = ocrEngine.DocumentManager.CreateDocument()
            ' Add a page to the document
            Dim 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 page
            ocrPage.Recognize(Nothing)

            ' Save the document we have as PDF
            ocrDocument.Save(pdfFileName, DocumentFormat.Pdf, Nothing)
         End Using

         ' Shutdown the engine
         ' Note: calling Dispose will also automatically shutdown the engine if it has been started
         ocrEngine.Shutdown()
      End Using
   Catch ex As OcrSupportLockedException
      Console.WriteLine("Support is locked. You need to unlock '{0}' in this engine to use this feature", ex.SupportType)
   Catch ex As OcrException
      Console.WriteLine("OCR Error" & vbLf & "Code: {0}" & vbLf & "Message:{1}", ex.Code, ex.Message)
   Catch ex As RasterException
      Console.WriteLine("LEADTOOLS Error" & vbLf & "Code: {0}" & vbLf & "Message:{1}", ex.Code, ex.Message)
   Catch ex As Exception
      Console.WriteLine("System Error" & vbLf & "Message:{0}", ex.Message)
   End Try
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
Public Const OcrAdvantageRuntimeDir As String = "C:\LEADTOOLS 19\Bin\Common\OcrAdvantageRuntime"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Forms.Ocr;
using Leadtools.Forms.DocumentWriters;

public void OcrExceptionExample()
{
   try
   {
      // Create an instance of the engine
      using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false))
      {
         // Start the engine using default parameters
         ocrEngine.Startup(null, null, null, LEAD_VARS.OcrAdvantageRuntimeDir);
         string tifFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif");
         string pdfFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.pdf");

         // Create a page
         // Create an OCR document
         using (IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument())
         {
            // Add a page to the document
            IOcrPage 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 page
            ocrPage.Recognize(null);

            // Save the document we have as PDF
            ocrDocument.Save(pdfFileName, DocumentFormat.Pdf, null);
         }

         // Shutdown the engine
         // Note: calling Dispose will also automatically shutdown the engine if it has been started
         ocrEngine.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 OcrAdvantageRuntimeDir = @"C:\LEADTOOLS 19\Bin\Common\OcrAdvantageRuntime";
}
Requirements

Target Platforms

See Also

Reference

OcrSupportLockedException Members
Leadtools.Forms.Ocr Namespace
OcrSupportLockedExceptionType Enumeration
IOcrEngine.Startup
IOcrEngine.IsStarted
IOcrEngine.Shutdown
OcrEngineManager Class
OcrEngineType Enumeration
Programming with the LEADTOOLS .NET OCR
Unlocking Special LEAD Features

Error processing SSI file
Leadtools.Forms.Ocr requires a Recognition or Document Imaging Suite license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features