[SerializableAttribute()]public enum OcrImageSharingMode
typedef NS_ENUM(NSInteger, LTOcrImageSharingMode) {LTOcrImageSharingModeNone,LTOcrImageSharingModeAutoDispose,};
public enum OcrImageSharingMode [SerializableAttribute()]public enum class OcrImageSharingMode
class OcrImageSharingMode(Enum):None = 0AutoDispose = 1
| Value | Member | Description |
|---|---|---|
| 0 | None | IOcrPage will not dispose the RasterImage when it is disposed. The page does not own the raster image. |
| 1 | AutoDispose | IOcrPage will dispose the RasterImage when it is disposed. The page owns the raster image. |
OcrImageSharingMode determines the ownership of the source raster image object passed to IOcrEngine.CreatePage.
using Leadtools;using Leadtools.Codecs;using Leadtools.Ocr;using Leadtools.Document.Writer;private static void CreatePageExample(){// 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[] tifFileNames ={Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif"),Path.Combine(LEAD_VARS.ImagesDir, "Ocr2.tif"),Path.Combine(LEAD_VARS.ImagesDir, "Ocr3.tif"),Path.Combine(LEAD_VARS.ImagesDir, "Ocr4.tif")};string pdfFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.pdf");// Create an OCR document to save the result as PDF// Create the document using file mode since we are not keeping the OCR pages in memoryusing (IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument(null, OcrCreateDocumentOptions.None)){foreach (string tifFileName in tifFileNames){// Load the TIFF file as imageRasterImage rasterImage = ocrEngine.RasterCodecsInstance.Load(tifFileName, 1);// Create an IOcrPage instance from this imageusing (IOcrPage ocrPage = ocrEngine.CreatePage(rasterImage, OcrImageSharingMode.AutoDispose)){// We told the page to dispose the image when no longer needed, so rasterImage should not be used anymorerasterImage = null;// Recognize the pageocrPage.Recognize(null);// Show the resultsstring text = ocrPage.GetText(-1);Console.WriteLine("Recognition text for " + tifFileName);Console.WriteLine(text);// Add this recognized pageocrDocument.Pages.Add(ocrPage);// The method above took a snapshot of the recognition data of the page and added it to the document// The page is no longer needed}}// Now we can save the documentocrDocument.Save(pdfFileName, DocumentFormat.Pdf, null);}}}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS23\Bin\Common\OcrLEADRuntime";}
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
