Working with Recognition Results (Delphi 6.0)

Take the following steps to add code to the existing project that will let you work with Recognition options:

1.

Start with the program you created in Working with Zones

2.

Add 2 buttons to your form and name them as follows:

 

Name

Caption

 

btnGetOutputFormat

Get Output Format

 

btnSaveDocument

Save Document

3.

Handle the LEADRasterDocument1 OnEnumOutputFileFormats event, and code the LEADRasterDocument1EnumOutputFileFormats procedure as follows:

procedure TForm1.LEADRasterDocument1EnumOutputFileFormats(ASender: TObject; 
  Format: TOleEnum); 
var
 nRet: Integer; 
begin
   nRet:= LEADRasterDocument1.GetFileFormatInfo ( Format ); 
   if ( nRet = 0 ) then
   begin
    ShowMessage ( 'Format Name = ' + LEADRasterDocument1.FileFormatInfo.FormatName + Chr(13) +
              'Format DLL Name = ' + LEADRasterDocument1.FileFormatInfo.DLLName + Chr(13) +
              'Format Ext Name = ' + LEADRasterDocument1.FileFormatInfo.ExtName ); 

    Case ( LEADRasterDocument1.FileFormatInfo.Type_ ) of
     OUTTYPE_PLAIN: 
        ShowMessage ( 'Format Type = Plain' ); 

     OUTTYPE_WORD_PROCESSOR: 
        ShowMessage ( 'Format Type = Word Processor' ); 

     OUTTYPE_TRUE_WORD_PROCESSOR: 
        ShowMessage ( 'Format Type = True Word Processor' ); 

   OUTTYPE_TABLE: 
        ShowMessage ( 'Format Type = Table' ); 

     OUTTYPE_UNKNOWN: 
        ShowMessage ( 'Format Type = Unknown' ); 
    end; 
   end; 
end;

4.

Code the btnGetOutputFormat button's click procedure as follows:

procedure TForm1.btnGetOutputFormatClick(Sender: TObject); 
var
 nRet: Integer; 
begin
 nRet:= LEADRasterDocument1.GetOutputFileFormats ( ); 
 if ( nRet <> 0 ) then
  ShowMessage ( 'Error' + IntToStr(nRet) + 'in enumerating available file formats' ); 
end;

5.

Code the btnSaveDocument button's click procedure as follows:

procedure TForm1.btnSaveDocumentClick(Sender: TObject); 
var
 nRet: Integer; 
begin
 nRet:= LEADRasterDocument1.GetRecognitionResultOptions ( ); 
 if ( nRet = 0 ) then
   begin
  LEADRasterDocument1.ResultOptions.FormatLevel:= FORMATLEVEL_FULL; 
  LEADRasterDocument1.ResultOptions.DocumentOptions.PaperSizeMode:= SELPREDEFINED; 
  LEADRasterDocument1.ResultOptions.DocumentOptions.PaperType:= PAPER_A4; 
 end; 

 LEADRasterDocument1.SetRecognitionResultOptions ( ); 
 nRet:= LEADRasterDocument1.SaveDocument ( 'c:\test.doc' ); 
 if ( nRet <> 0 ) then
  ShowMessage ( 'Error' + IntToStr(nRet) + 'in saving recognition result to a file' ); 
end;

6.

Run your program to test it.

7.

Save the project to use as a starting point for other tasks in this tutorial.