←Select platform

OcrSupportLockedExceptionType Enumeration

Summary
The type of support (feature) needing to be unlocked that caused the error.
Syntax
C#
C++/CLI
Java
Python
[SerializableAttribute()] 
public enum OcrSupportLockedExceptionType 
public enum OcrSupportLockedExceptionType 
[SerializableAttribute()] 
public enum class OcrSupportLockedExceptionType   
class OcrSupportLockedExceptionType(Enum): 
   Ocr = 0 
   Icr = 1 
   Omr = 2 
   Pdf = 3 
   PdfA = 4 
   OcrOmniPageArabic = 5 
   EnginePdf = 6 
   OcrOmniPageAsian = 7 
Members
ValueMemberDescription
0Ocr OCR support is required to use this feature.
1Icr ICR (handprint) support is required to use this feature.
2Omr OMR support is required to use this feature.
3Pdf PDF support is required to use this feature (When saving a document using the LEADTOOLS Document Writers, refer to IOcrDocument.Save.
4PdfA (Deprecated) Do not use.
6EnginePdf PDF support is required to use this feature (When saving a document using the engine native support, refer to IOcrDocumentManager.EngineFormat.
Remarks

Various parts of the LEADTOOLS OCR toolkit are locked by a specific key. When using these features without first unlocking the specified feature, an exception of type OcrSupportLockedException will be thrown. You can examine the OcrSupportLockedException.SupportType property to determine which unlock support feature is required.

The following table lists the action required when an error of type OcrSupportLockedException is thrown:

Engine type OcrSupportLockedException.SupportType value Action required
LEADTOOLS OCR Module - LEAD Engine (OcrEngineType.LEAD) OcrSupportLockedExceptionType.Ocr Unlock RasterSupportType.OcrLEAD
LEADTOOLS OCR Module - LEAD Engine (OcrEngineType.LEAD) OcrSupportLockedExceptionType.Pdf Unlock RasterSupportType.OcrLEADPdfOutput
LEADTOOLS OCR Module - LEAD Engine (OcrEngineType.LEAD) OcrSupportLockedExceptionType.PdfA Unlock RasterSupportType.OcrLEADPdfOutput

Note at this time, LEADTOOLS OCR Module - LEAD Engine (OcrEngineType.LEAD) is not supported.

For more information on feature support and how to obtain the unlock keys, refer to Unlocking Special LEAD Features, RasterSupport and RasterSupportType.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Ocr; 
using Leadtools.Document.Writer; 
 
public void OcrExceptionExample() 
{ 
   try 
   { 
      // Create an instance of the engine 
      using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD)) 
      { 
         // Start the engine using default parameters 
         ocrEngine.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 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:\LEADTOOLS23\Resources\Images"; 
   public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS23\Bin\Common\OcrLEADRuntime"; 
} 
 
import static org.junit.Assert.assertTrue; 
 
import java.io.File; 
import java.io.IOException; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
 
import leadtools.*; 
import leadtools.document.writer.DocumentFormat; 
import leadtools.ocr.*; 
 
 
public void OcrExceptionExample() { 
   final String LEAD_VARS_OCR_LEAD_RUNTIME_DIR = "C:\\LEADTOOLS23\\Bin\\Common\\OcrLEADRuntime"; 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
 
   try { 
      // Create an instance of the engine 
      OcrEngine ocrEngine = OcrEngineManager.createEngine(OcrEngineType.LEAD); 
 
      // Start the engine using default parameters 
      ocrEngine.startup(null, null, null, LEAD_VARS_OCR_LEAD_RUNTIME_DIR); 
 
      String pdfFileName = combine(LEAD_VARS_IMAGES_DIR, "pdfsegmentation.pdf"); 
      ILeadStream leadStream = LeadStreamFactory.create("C:\\LEADTOOLS23\\Resources\\Images\\Ocr1.tif"); 
 
      // Create a page 
      // Create an OCR document 
      OcrDocument ocrDocument = ocrEngine.getDocumentManager().createDocument(); 
 
      // Add a page to the document 
      OcrPage ocrPage = ocrDocument.getPages().addPage(leadStream, 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); 
      assertTrue("File unsuccessfully saved", new File(pdfFileName).exists()); 
      System.out.printf("Command run, file saved to %s", pdfFileName); 
 
      // Shutdown the engine 
      // Note: calling Dispose will also automatically shutdown the engine if it has 
      // been started 
      ocrEngine.shutdown(); 
 
   } catch (OcrSupportLockedException ex) { 
      System.out.printf( 
         "Support is locked. You need to unlock '%s' in this engine to use this feature", 
         ex.getSupportType() 
      ); 
   } catch (OcrException ex) { 
      System.out.printf( 
         "OCR Error\nCode: %s\nMessage:%s", ex.getCode(), ex.getMessage() 
      ); 
   } catch (RasterException ex) { 
      System.out.printf( 
         "LEADTOOLS Error\nCode: %s\nMessage:%s", ex.getCode(), ex.getMessage() 
      ); 
   } catch (Exception ex) { 
      System.out.printf( 
         "System Error\nMessage:%s", ex.getMessage() 
      ); 
   } 
} 
Requirements

Target Platforms

Help Version 23.0.2024.4.19
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Ocr Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.