public long Code { get; set; } public final long getCode()public final void setCode(long value)
Code # get and set (OcrException)
An value that represents the engine-specific error code that is the cause of this exception.
The Message property of this OcrException will contain the same description used in IOcrEngine.GetErrorCodeString.
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)){// 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:\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 engineOcrEngine ocrEngine = OcrEngineManager.createEngine(OcrEngineType.LEAD);// Start the engine using default parametersocrEngine.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 documentOcrDocument ocrDocument = ocrEngine.getDocumentManager().createDocument();// Add a page to the documentOcrPage 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 pageocrPage.recognize(null);// Save the document we have as PDFocrDocument.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 startedocrEngine.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());}}
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
