←Select platform

CurrentPageIndex Property

Summary
Gets the zero-based index of the current page being processed by the operation.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public int CurrentPageIndex { get; } 
@property (nonatomic, assign, readonly) NSInteger currentPageIndex 
public int getCurrentPageIndex() 
property int CurrentPageIndex { 
   int get(); 
} 
CurrentPageIndex # get  (IOcrProgressData) 

Property Value

The zero-based index of the current page being processed by the operation.

Remarks

FirstPageIndex and LastPageIndex corresponds to the index in the IOcrPageCollection of the first and last pages when a method such as Recognize(int firstPageIndex, int lastPageIndex, OcrProgressCallback callback) is called.

If a method that operates on a single page is called, such as IOcrPage.Recognize, then FirstPageIndex and LastPageIndex will be the same value and are equal to the index of IOcrPage in the IOcrPageCollection.

CurrentPageIndex is the index of the current page the operation is processing. CurrentPageIndex will run from FirstPageIndex to LastPageIndex.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Ocr; 
using Leadtools.Document.Writer; 
using Leadtools.Forms.Common; 
using Leadtools.WinForms; 
 
public void OcrProgressCallbackExample() 
{ 
   string logFileName = Path.Combine(LEAD_VARS.ImagesDir, "log.txt"); 
   string multiPageTifFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr.tif"); 
   string pdfFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.pdf"); 
 
   // Create the log text writer 
   _log = File.CreateText(logFileName); 
 
   // 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); 
 
      // Create an OCR document 
      using (IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument()) 
      { 
         // Add this image to the document 
         _log.WriteLine("Adding the pages"); 
         _log.WriteLine("********************************"); 
         ocrDocument.Pages.AddPages(multiPageTifFileName, 1, -1, new OcrProgressCallback(MyOcrProgressCallback)); 
 
         // Auto-recognize the zones in all the pages 
         _log.WriteLine("Auto-zoning"); 
         _log.WriteLine("********************************"); 
         ocrDocument.Pages.AutoZone(new OcrProgressCallback(MyOcrProgressCallback)); 
 
         // Recognize it and save it as PDF 
         _log.WriteLine("Recognizing"); 
         _log.WriteLine("********************************"); 
         ocrDocument.Pages.Recognize(new OcrProgressCallback(MyOcrProgressCallback)); 
         _log.WriteLine("Saving to PDF"); 
         _log.WriteLine("********************************"); 
         ocrDocument.Save(pdfFileName, DocumentFormat.Pdf, new OcrProgressCallback(MyOcrProgressCallback)); 
      } 
 
      // Shutdown the engine 
      // Note: calling Dispose will also automatically shutdown the engine if it has been started 
      ocrEngine.Shutdown(); 
   } 
 
   _log.WriteLine("********************************"); 
   _log.WriteLine("Complete"); 
   _log.Flush(); 
   _log.Close(); 
} 
// Text writer to save the log to 
private StreamWriter _log; 
 
private void MyOcrProgressCallback(IOcrProgressData data) 
{ 
   if (data.Percentage == 0) 
      _log.WriteLine("--------------------------"); 
 
   _log.WriteLine("Page:{0}({1}:{2}) {3}% Operation:{4}", 
      data.CurrentPageIndex.ToString("00"), 
      data.FirstPageIndex.ToString("00"), 
      data.LastPageIndex.ToString("00"), 
      data.Percentage.ToString("000"), 
      data.Operation); 
} 
 
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.