←Select platform

Code Property

Summary
Gets or sets the engine-specific error code that is the cause of this exception.
Syntax
C#
C++/CLI
Java
Python
public long Code { get; set; } 
public final long getCode() 
public final void setCode(long value) 
public: 
property int64 Code { 
   int64 get(); 
   void set (    int64 ); 
} 
Code # get and set (OcrException) 

Property Value

An value that represents the engine-specific error code that is the cause of this exception.

Remarks

The Message property of this OcrException will contain the same description used in IOcrEngine.GetErrorCodeString.

Example
C#
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:\LEADTOOLS22\Resources\Images"; 
   public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS22\Bin\Common\OcrLEADRuntime"; 
} 
Requirements

Target Platforms

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

Leadtools.Ocr Assembly

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