←Select platform

OcrImageSharingMode Enumeration

Summary
Options used with IOcrEngine.CreatePage to determine the ownership of the source raster image.
Syntax
C#
Objective-C
C++/CLI
Java
Python
[SerializableAttribute()] 
public enum OcrImageSharingMode   
typedef NS_ENUM(NSInteger, LTOcrImageSharingMode) { 
 LTOcrImageSharingModeNone,  
 LTOcrImageSharingModeAutoDispose,  
}; 
public enum OcrImageSharingMode 
[SerializableAttribute()] 
public enum class OcrImageSharingMode   
class OcrImageSharingMode(Enum): 
   None = 0 
   AutoDispose = 1 
Members
ValueMemberDescription
0None IOcrPage will not dispose the RasterImage when it is disposed. The page does not own the raster image.
1AutoDispose IOcrPage will dispose the RasterImage when it is disposed. The page owns the raster image.
Remarks

OcrImageSharingMode determines the ownership of the source raster image object passed to IOcrEngine.CreatePage.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Ocr; 
using Leadtools.Document.Writer; 
 
private static void CreatePageExample() 
{ 
   // 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[] 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 memory 
      using (IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument(null, OcrCreateDocumentOptions.None)) 
      { 
         foreach (string tifFileName in tifFileNames) 
         { 
            // Load the TIFF file as image 
            RasterImage rasterImage = ocrEngine.RasterCodecsInstance.Load(tifFileName, 1); 
 
            // Create an IOcrPage instance from this image 
            using (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 anymore 
               rasterImage = null; 
 
               // Recognize the page 
               ocrPage.Recognize(null); 
 
               // Show the results 
               string text = ocrPage.GetText(-1); 
               Console.WriteLine("Recognition text for " + tifFileName); 
               Console.WriteLine(text); 
 
               // Add this recognized page 
               ocrDocument.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 document 
         ocrDocument.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"; 
} 
Requirements

Target Platforms

See Also

Reference

Leadtools.Ocr Namespace

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.