Take the following steps to add code to the existing project that
will let you deal with the OCR Recognition Results:
Start with the program you created in COM Interoperability Recognizing Pages 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: Property Value Caption Get Output Format Change the following properties of Command9: Property Value Caption Save Document 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
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
Build, and Run the program to test it. Save this project to use for testing other code samples.