Recognizing Pages

Take the following steps to add code to the existing project that will let you recognize pages:

1.

Start with the program you created in Working with Zones.

2.

Add a command button to your form and name it as follows:

 

Name

Caption

 

RECOGNIZE

Recognize

 

GETSTATUS

Get Status

3.

Code the RECOGNIZE button's click procedure as follows:

Private Sub RECOGNIZE_Click()
Dim nRet As Long
LEADRasterDoc.SpellLanguageID = LANGID_ENGLISH
LEADRasterDoc.EnableSubSystem = True
LEADRasterDoc.EnableCorrection = True
   
LEADRasterDoc.RecognitionDataFileName = "c:\testrdf.rdf"

nRet = LEADRasterDoc.RECOGNIZE(0, 1) 
If (nRet = 0) Then
MsgBox "The engine finished recognizing the specified pages successfully"
Else
MsgBox "Error" + Str(nRet) + "in recognized specified pages"
End If
End Sub

4.

Code the GETSTATUS button's click procedure as follows:

Private Sub GETSTATUS_Click()
Dim nRet As Long
nRet = LEADRasterDoc.GetStatus ()
If (nRet = 0) Then
MsgBox "Recognition Time = " + Str(LEADRasterDoc.RecognizeStatus.RecognizedTime) + Chr$(13) + _
      "Total Recognized Characters = " + Str(LEADRasterDoc.RecognizeStatus.RecognizedCharacterCount) + Chr$(13) + _
      "Total Recognized Words = " + Str(LEADRasterDoc.RecognizeStatus.RecognizedWordCount) + Chr$(13) + _
      "Total Rejected Characters = " + Str(LEADRasterDoc.RecognizeStatus.RejectCharacterCount) + Chr$(13) + _
      "Total Rejected Words = " + Str(LEADRasterDoc.RecognizeStatus.RejectWordCount
End If
End Sub 

5.

Code the RecognitionStatus Event procedure as follows:

Private Sub LEADRasterDoc_RecognitionStatus (ByVal iRecogPage As Integer, ByVal iError As Integer) 
MsgBox "The page # " + Str(iRecogPage) + "is finished its recognition" + Chr$(13) + _
      "The recognition return code = " + Str(iError) 
' continue to recognize next page
   LEADRasterDoc.EnableStopRecognizeStatus = False
End Sub

6.

Run your program to test it.

7.

Save this project to use for testing other code samples.