Working with Recognition Results
Take the following steps to add code to the existing project that will let you recognize pages:
1. |
Start with the program you created in Recognize Pages. | |
2. |
In Resource View tab, open the EZFUNC resources, and open MAIN_MENU1 menu to add the a new menu item as follows: | |
|
a. |
Select an empty rectangle in the menu, and right click on that box and select Properties. |
|
b. |
Set the ID to IDM_GET_OUTPUTFORMAT and the Caption to Get Output Formats. Make sure Checked has been selected. Press Enter. |
|
c. |
Another rectangle appears on the menu. Right click on that box and select Properties. |
|
d. |
Set the ID to IDM_SAVE_RESULTS and the Caption to Save Results. Make sure Checked has been selected. Press Enter. |
3. |
In the MainWndProc procedure, add the following code to the switch statement for WM_COMMAND: |
case IDM_GET_OUTPUTFORMAT:
{
nRet = L_DocEnumOutputFileFormats(hDoc, EnumOutputFileFormatsCB, NULL);
if (nRet != SUCCESS)
{
wsprintf (achBuff, TEXT("Error %d enumerating available file formats"), nRet);
MessageBox (NULL, achBuff, TEXT("Error"), MB_OK);
}
}
break;
case IDM_SAVE_RESULTS:
{
RESULTOPTIONS ResOpts;
memset(&ResOpts, 0, sizeof(RESULTOPTIONS));
nRet = L_DocGetRecognitionResultOptions(hDoc, &ResOpts, sizeof(RESULTOPTIONS));
if (nRet == SUCCESS)
{
ResOpts.FormatLevel = FORMAT_LEVEL_FULL;
ResOpts.DocOptions.PaperSize = SEL_PREDEFINED;
ResOpts.DocOptions.PaperType = PAPER_TYPE_A4;
L_DocSetRecognitionResultOptions(hDoc, &ResOpts);
nRet = L_DocSaveResultsToFile (hDoc, TEXT("c:\\test.doc"));
if (nRet != SUCCESS)
{
wsprintf (achBuff, TEXT("Error %d in saving recognition results to a file"), nRet);
MessageBox (NULL, achBuff, TEXT("Error"), MB_OK);
}
}
}
break;
4. |
Add the following function in EZFUNC.C in EZOCRDOC directory. |
L_INT EXT_FUNCTION EnumOutputFileFormatsCB(FORMAT_TYPE Format, L_VOID L_FAR * pUserData)
{
TEXTFORMATINFO FormatInfo;
L_INT nRet;
L_TCHAR szBuffer[1024];
memset(&FormatInfo, 0, sizeof(TEXTFORMATINFO));
nRet = L_DocGetTextFormatInfo(hDoc, Format, &FormatInfo, sizeof(TEXTFORMATINFO));
if (nRet == SUCCESS)
{
wsprintf(szBuffer, TEXT("Format Name = %s\nFormat DLL Name = %s\nFormat Ext Name = %s\n"),
FormatInfo.pszName,
FormatInfo.pszDLLName,
FormatInfo.pszExtName);
MessageBox(NULL, szBuffer, TEXT("Format Info"), MB_OK);
switch (FormatInfo.Type)
{
case OUT_TYPE_PLAIN:
wsprintf(szBuffer, TEXT("Format Type = Plain"));
break;
case OUT_TYPE_WORD_PROCESSOR:
wsprintf(szBuffer, TEXT("Format Type = Word Processor"));
break;
case OUT_TYPE_TRUE_WORD_PROCESSOR:
wsprintf(szBuffer, TEXT("Format Type = True Word Processor"));
break;
case OUT_TYPE_TABLE:
wsprintf(szBuffer, TEXT("Format Type = Table"));
break;
case OUT_TYPE_UNKNOWN:
wsprintf(szBuffer, TEXT("Format Type = Unknown"));
break;
}
MessageBox(NULL, szBuffer, TEXT("Format Type"), MB_OK);
}
return SUCCESS;
}
5. |
Also, add the following statement before the MainWndProc function |
L_INT EXT_FUNCTION EnumOutputFileFormatsCB(FORMAT_TYPE Format, L_VOID L_FAR * pUserData);
6. |
Build Ezfunc32.exe. |
7. |
Run Ezfunc32.exe. |