Working with Recognition Results
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 |
|
GETOUTPUTFORMAT |
Get Output Format |
|
SAVEDOCUMENT |
Save Document |
3. |
Code the GETOUTPUTFORMAT button's click procedure as follows: |
Private Sub GETOUTPUTFORMAT_Click()
Dim nRet As Long
nRet = LEADRasterDoc.GetOutputFileFormats
If (nRet <> 0) Then
MsgBox "Error" + Str(nRet) + "in enumerating available file formats"
End If
End Sub
4. |
Code the SAVEDOCUMENT button's click procedure as follows: |
Private Sub SAVEDOCUMENT_Click()
Dim nRet As Long
nRet = LEADRasterDoc.GetRecognitionResultOptions
If (nRet = 0) Then
LEADRasterDoc.ResultOptions.FormatLevel = FORMATLEVEL_FULL
LEADRasterDoc.ResultOptions.DocumentOptions.PaperSizeMode = SELPREDEFINED
LEADRasterDoc.ResultOptions.DocumentOptions.PaperType = PAPER_A4
End If
LEADRasterDoc.SetRecognitionResultOptions
nRet = LEADRasterDoc.SaveDocument ("c:\test.doc")
If (nRet <> 0) Then
MsgBox "Error" + Str(nRet) + "in saving recognition result to a file"
End If
End Sub
5. |
Code the EnumOutputFileFormats Event procedure as follows: |
Private Sub LEADRasterDoc_EnumOutputFileFormats (ByVal Format As LTRASTERDOCLib.FORMATTYPE)
Dim nRet As Long
nRet = LEADRasterDoc.GetFileFormatInfo (Format)
If (nRet = 0) Then
MsgBox "Format Name = " + LEADRasterDoc.FileFormatInfo.FormatName + Chr$(13) + _
"Format DLL Name = " + LEADRasterDoc.FileFormatInfo.DLLName + Chr$(13) + _
"Format Ext Name = " + LEADRasterDoc.FileFormatInfo.ExtName
Select Case (LEADRasterDoc.FileFormatInfo.Type)
Case OUTTYPE_PLAIN
MsgBox "Format Type = Plain"
Case OUTTYPE_WORD_PROCESSOR
MsgBox "Format Type = Word Processor"
Case OUTTYPE_TRUE_WORD_PROCESSOR:
MsgBox "Format Type = True Word Processor"
Case OUTTYPE_TABLE
MsgBox "Format Type = Table"
Case OUTTYPE_UNKNOWN
MsgBox "Format Type = Unknown"
End Select
End If
End Sub
6. |
Run your program to test it. |
7. |
Save this project to use for testing other code samples. |