Working with Recognition Results (C++ Builder 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: |
void __fastcall TForm1::LEADRasterDocument1EnumOutputFileFormats(
TObject *Sender, FORMATTYPE Format)
{
int nRet;
AnsiString Msg;
nRet= LEADRasterDocument1->GetFileFormatInfo ( Format );
if ( nRet == 0 )
{
Msg= "Format Name = ";
Msg= Msg + LEADRasterDocument1->FileFormatInfo->FormatName + "\n";
Msg= Msg + "Format DLL Name = ";
Msg= Msg + LEADRasterDocument1->FileFormatInfo->DLLName+ "\n";
Msg= Msg + "Format Ext Name = ";
Msg= Msg + LEADRasterDocument1->FileFormatInfo->ExtName;
ShowMessage ( Msg );
switch ( LEADRasterDocument1->FileFormatInfo->Type)
{
case OUTTYPE_PLAIN:
ShowMessage ( "Format Type = Plain" );
break;
case OUTTYPE_WORD_PROCESSOR:
ShowMessage ( "Format Type = Word Processor" );
break;
case OUTTYPE_TRUE_WORD_PROCESSOR:
ShowMessage ( "Format Type = True Word Processor" );
break;
case OUTTYPE_TABLE:
ShowMessage ( "Format Type = Table" );
break;
case OUTTYPE_UNKNOWN:
ShowMessage ( "Format Type = Unknown" );
break;
}
}
}
4. |
Code the btnGetOutputFormat button's click procedure as follows: |
void __fastcall TForm1::btnGetOutputFormatClick(TObject *Sender)
{
int nRet;
nRet= LEADRasterDocument1->GetOutputFileFormats ( );
if ( nRet != 0 )
ShowMessage ( "Error" + IntToStr(nRet) + "in enumerating available file formats" );
}
5. |
Code the btnSaveDocument button's click procedure as follows: |
void __fastcall TForm1::btnSaveDocumentClick(TObject *Sender)
{
int nRet;
nRet= LEADRasterDocument1->GetRecognitionResultOptions ( );
if ( nRet == 0 )
{
LEADRasterDocument1->ResultOptions->FormatLevel= FORMATLEVEL_FULL;
LEADRasterDocument1->ResultOptions->DocumentOptions->PaperSizeMode= SELPREDEFINED;
LEADRasterDocument1->ResultOptions->DocumentOptions->PaperType= PAPER_A4;
}
LEADRasterDocument1->SetRecognitionResultOptions ( );
nRet= LEADRasterDocument1->SaveDocument ( AnsiToOLESTR("c:\\test.doc") );
if ( nRet != 0 )
ShowMessage ( "Error" + IntToStr(nRet) + "in saving recognition result to a file" );
}
6. |
Run your program to test it. |
7. |
Save the project to use as a starting point for other tasks in this tutorial. |