Leadtools.Forms.Ocr Requires Document/Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
OcrSupportLockedException Class
See Also  Members   Example 
Leadtools.Forms.Ocr Namespace : OcrSupportLockedException Class



The exception that is thrown when a support locked runtime error occurs inside the IOcrEngine.

Syntax

Visual Basic (Declaration) 
<SerializableAttribute()>
Public Class OcrSupportLockedException 
   Inherits Exception
Visual Basic (Usage)Copy Code
Dim instance As OcrSupportLockedException
C# 
[SerializableAttribute()]
public class OcrSupportLockedException : Exception 
C++/CLI 
[SerializableAttribute()]
public ref class OcrSupportLockedException : public Exception 

Example

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

Visual BasicCopy Code
Public Sub OcrExceptionExample()
   ' Unlock the support needed for LEADTOOLS Plus OCR engine
   RasterSupport.Unlock(RasterSupportType.Document, "Replace with your own key here")
   RasterSupport.Unlock(RasterSupportType.OcrPlus, "Replace with your own key here")
   RasterSupport.Unlock(RasterSupportType.OcrPlusPdfLeadOutput, "Replace with your own key here")
   Try
      ' Create an instance of the engine
      Using ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Plus, False)
         ' Start the engine using default parameters
         ocrEngine.Startup(Nothing, Nothing, Nothing, Nothing)

         Dim tifFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.tif"
         Dim pdfFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.pdf"

         ' 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\nCode: {0}\nMessage:{1}", ex.Code, ex.Message)
   Catch ex As RasterException
      Console.WriteLine("LEADTOOLS Error\nCode: {0}\nMessage:{1}", ex.Code, ex.Message)
   Catch ex As Exception
      Console.WriteLine("System Error\nMessage:{0}", ex.Message)
   End Try
End Sub
C#Copy Code
public void OcrExceptionExample() 

   // Unlock the support needed for LEADTOOLS Plus OCR engine 
   RasterSupport.Unlock(RasterSupportType.Document, "Replace with your own key here"); 
   RasterSupport.Unlock(RasterSupportType.OcrPlus, "Replace with your own key here"); 
   RasterSupport.Unlock(RasterSupportType.OcrPlusPdfLeadOutput, "Replace with your own key here"); 
   try 
   { 
      // Create an instance of the engine 
      using(IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Plus, false)) 
      { 
         // Start the engine using default parameters 
         ocrEngine.Startup(null, null, null, null); 
 
         string tifFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.tif"; 
         string pdfFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.pdf"; 
 
         // 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); 
   } 
}

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.

Inheritance Hierarchy

System.Object
   System.Exception
      Leadtools.Forms.Ocr.OcrSupportLockedException

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also

OcrSupportLockedException requires an OCR module license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features