Leadtools.Document Deprecated as of v16. Refer to: Leadtools.Forms.Ocr | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
RasterDocumentRecognizeStatusCallback Delegate
See Also  Example
Leadtools.Document Namespace : RasterDocumentRecognizeStatusCallback Delegate



pageIndex
Specifies the index for the recognized page.
code
Specifies the error value.
The page recognition status event

Syntax

Visual Basic (Declaration) 
Public Delegate Function RasterDocumentRecognizeStatusCallback( _
   ByVal pageIndex As Integer, _
   ByVal code As RasterDocumentExceptionCode _
) As Boolean
Visual Basic (Usage)Copy Code
Dim instance As New RasterDocumentRecognizeStatusCallback(AddressOf HandlerMethod)
C# 
public delegate bool RasterDocumentRecognizeStatusCallback( 
   int pageIndex,
   RasterDocumentExceptionCode code
)
C++/CLI 
public delegate bool RasterDocumentRecognizeStatusCallback( 
   int pageIndex,
   RasterDocumentExceptionCode code
)

Parameters

pageIndex
Specifies the index for the recognized page.
code
Specifies the error value.

Example

Visual BasicCopy Code
Public Function RasterDocument_RecognizeStatus(ByVal pageIndex As Integer, ByVal code As RasterDocumentExceptionCode) As Boolean
   Dim buffer As String = String.Format("Recognized page index = {0}" & Constants.vbLf & "Recognition Return value = {1}", pageIndex, code)
   MessageBox.Show(buffer)
   Return False
End Function

Public Sub RasterDocumentRecognizeStatusCallbackExample()
   ' Note that this is a sample key, which will not work in your toolkit
   RasterSupport.Unlock(Leadtools.RasterSupportType.Ocr, "TestKey")

   Dim rasterDocument As RasterDocumentEngine
   rasterDocument = RasterDocumentEngine.Instance
   rasterDocument.Startup()
   'assume page is added, refer to AddPage example for more information

   Dim langs As RasterDocumentLanguage() = rasterDocument.DefaultSpellLanguages()
   MessageBox.Show("Totat Default Spell Languages = " & langs.Length)

   If langs.Length > 0 Then
      If rasterDocument.RecognizeModuleTradeoff <> RasterDocumentTradeoff.Accurate Then
         rasterDocument.RecognizeModuleTradeoff = RasterDocumentTradeoff.Accurate
      End If

      rasterDocument.EnableSubsystem = True
      rasterDocument.EnableCorrection = True
      rasterDocument.SpellLanguageId = langs(0)
      rasterDocument.EnableEvents()
      rasterDocument.RecognitionDataFileName = LeadtoolsExamples.Common.ImagesPath.Path + "test.rdf"

      rasterDocument.Recognize(0, 1, AddressOf RasterDocument_RecognizeStatus)
   End If

   rasterDocument.Shutdown()
End Sub
C#Copy Code
public bool RasterDocument_RecognizeStatus(int pageIndex, RasterDocumentExceptionCode code) 

   string buffer = string.Format("Recognized page index = {0}\nRecognition Return value = {1}", pageIndex, code); 
   MessageBox.Show(buffer); 
   return false; 

 
public void RasterDocumentRecognizeStatusCallbackExample() 

   RasterDocumentEngine rasterDocument; 
   rasterDocument = RasterDocumentEngine.Instance; 
   rasterDocument.Startup(); 
   // Note that this is a sample key, which will not work in your toolkit 
   RasterSupport.Unlock(RasterSupportType.Ocr, "TestKey"); 
 
   // assume page is added, refer to AddPage example for more information 
 
   RasterDocumentLanguage[] langs = rasterDocument.DefaultSpellLanguages(); 
   MessageBox.Show("Totat Default Spell Languages = " + langs.Length); 
 
   if (langs.Length > 0) 
   { 
      if (rasterDocument.RecognizeModuleTradeoff != RasterDocumentTradeoff.Accurate) 
         rasterDocument.RecognizeModuleTradeoff = RasterDocumentTradeoff.Accurate; 
 
      rasterDocument.EnableSubsystem = true; 
      rasterDocument.EnableCorrection = true; 
      rasterDocument.SpellLanguageId = langs[0]; 
      rasterDocument.EnableEvents(); 
      rasterDocument.RecognitionDataFileName = LeadtoolsExamples.Common.ImagesPath.Path + "test.rdf"; 
 
      rasterDocument.Recognize(0, 1, RasterDocument_RecognizeStatus); 
   } 
 
   rasterDocument.Shutdown(); 
}

Remarks

This event is invoked after each page is recognized, by calling the Recognize method. It reports the recognized page index along with the error code (status) that was returned by the recognition process.

To enable using this event, call EnableEvents. To disable using this event, call DisableEvents.

When you create a RasterDocumentRecognizeStatusCallback delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate.

Delegates are similar to the method pointers of C++ and have two main uses: performing callbacks, and defining events. Delegates are defined at run time.

Callback methods allow asynchronous processing: the method being called starts a thread and returns, during which time the thread does most of the work and calls the callback only when needed.

Events use a publish and subscribe type pattern. A class 'publishes' an event and any number of classes can 'subscribe' to that event. The runtime notifies subscribers when an event occurs.

Delegates that are used in defining events must be defined as taking two arguments: a publisher object, and an event information object (derived from the .NET EventArgs class).

For more information, refer to Recognizing Document Pages.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also

The Leadtools.Document namespace is deprecated and no longer supported as of LEADTOOLS v16. For v16 and later, please refer to: Leadtools.Forms.Ocr. This documentation is retained for v15 and earlier informational use only.