Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.12.21
COM Interoperability: Working with Recognition Results
Take the following steps to add code to the existing project that will let you deal with the OCR Recognition Results:
  1. Start with the program you created in COM Interoperability Recognizing Pages
  2. Drag and drop two command buttons in Form1. Leave all the buttons names as the default "Command8, Command9 ...", then change the following properties of Command8:
    PropertyValue
    CaptionGet Output Format
  3. Change the following properties of Command9:
    PropertyValue
    CaptionSave Document
  4. Add the following code for the Command8 control’s click procedure:
    
    Private Sub Command8_Click()
       ' Start an enumeration through all the available file formats
       Dim fileInfo As RasterDocumentFileFormatInfo
       documentEngine.AvailableOutputFileFormats
    
       Dim count As Integer
       count = documentEngine.OutputFileFormatsCount
    
       Dim i As Integer
       For i = 0 To count - 1
          Set fileInfo = documentEngine.GetTextFormatInfo(documentEngine.OutputFileFormats.Item(i))
    
          Dim msg As String
          ' Print some information about the current format
          msg = "Format Name = " + fileInfo.FormatName + Chr(13) + _
                "Format DLL Name = " + fileInfo.DllName + Chr(13) + _
                "Format Ext = " + fileInfo.ExtensionName + Chr(13) + _
                "Format Type = " + CStr(fileInfo.Type)
          MsgBox msg
       Next
    End Sub
    
  5. Add the following code for the Command9 control’s click procedure:
    
    Private Sub Command9_Click()
       ' Set the RasterDocumentResultOptions format
       Dim resultOptions As RasterDocumentResultOptions
       Dim docOpts As RasterDocumentOptions
       Set resultOptions = documentEngine.SaveResultOptions
       Set docOpts = resultOptions.Document
    
       docOpts.PaperType = RasterDocumentPaperType_A4
       docOpts.PaperSizeMode = RasterDocumentSelector_Predefined
       Set resultOptions.Document = docOpts
    
       resultOptions.FormatLevel = RasterDocumentFormatLevel_Full
       resultOptions.Format = RasterDocumentFormatType_Word972000XP
    
       Set documentEngine.SaveResultOptions = resultOptions
    
       ' Save the result of the recognition in a file
       documentEngine.SaveResultsToFile "C:\OcrTest.doc"
       MsgBox "The file has been successfully saved"
    End Sub
    
  6. Build, and Run the program to test it.
  7. Save this project to use for testing other code samples.