Working with Recognition Results (Visual Basic Script)

Take the following steps to add code to the existing project that will let you save the recognition results:

1.

Start with the program you created in Recognizing Pages.

2.

Add the following code between the <BODY> and </BODY> tags to add three buttons to the page:

<INPUT TYPE="button" VALUE="Get Output Format" LANGUAGE="VBScript"
         OnClick="GetOutputFormat" ID="Button9" NAME="Button8">

<INPUT TYPE="button" VALUE="Save Document" LANGUAGE="VBScript"
         OnClick="SaveDocument" ID="Button10" NAME="Button8">

3.

Add the following code between the <SCRIPT> and </SCRIPT> tags:

Sub GetOutputFormat()
         Dim nRet
         nRet = LEADRasterDoc.GetOutputFileFormats
         If (nRet <> 0) Then
            MsgBox "Error" + CStr(nRet) + "in enumerating available file formats"
         End If
End Sub

Sub SaveDocument()
         Dim nRet
         Dim FORMATLEVEL_FULL
         Dim SELPREDEFINED
         Dim PAPER_A4

         FORMATLEVEL_FULL =  0
         SELPREDEFINED = 2
         PAPER_A4 = 0

         nRet = LEADRasterDoc.GetRecognitionResultOptions
         MsgBox "Format Name = " + LEADRasterDoc.FileFormatInfo.FormatName + Chr(13) + _
               "Format DLL Name = " + LEADRasterDoc.FileFormatInfo.DLLName + Chr(13) + _
               "Format Ext Name = " + LEADRasterDoc.FileFormatInfo.ExtName
         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" + CStr(nRet) + "in saving recognition result to a file"
         End If
End Sub

4.

Add the following code between the <HEAD> and </HEAD> tags to handle the EnumOutputFileFormats event:

<SCRIPT LANGUAGE="VBScript" FOR="LEADRasterDoc" EVENT="EnumOutputFileFormats(Format)">
<!--
         Dim nRet
         Dim OUTTYPE_WORD_PROCESSOR
         Dim OUTTYPE_TRUE_WORD_PROCESSOR
         Dim OUTTYPE_TABLE
         Dim OUTTYPE_UNKNOWN

         OUTTYPE_WORD_PROCESSOR = 1
         OUTTYPE_TRUE_WORD_PROCESSOR = 2
         OUTTYPE_TABLE = 3
         OUTTYPE_UNKNOWN = 4

         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
//-->
</SCRIPT>

5.

Run your page to test it.