L_DocSaveResultsToFile

#include "ltdoc.h"

L_LTDOC_API L_INT L_DocSaveResultsToFile(hDoc, pszFileName)

L_HDOC hDoc;

/* handle to the OCR document */

L_TCHAR * pszFileName;

/* the output file name */

Saves the recognition results to a file.

Parameter

Description

hDoc

Handle to the OCR document.

pszFileName

Character string which contains the name of the output file to be saved.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Saves the recognition results to a file.

To recognize one or more pages, call L_DocRecognize.

To set save recognition results options, call L_DocSetRecognitionResultOptions.

To get the current save recognition results options, call L_DocGetRecognitionResultOptions.

To get all supported output formats, call L_DocEnumOutputFileFormats.

Required DLLs and Libraries

LTDOC

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

L_DocGetStatus, L_DocRecognize, L_DocSaveResultsToMemory, L_DocFreeMemoryResults, L_DocSetRecognitionResultOptions, L_DocGetRecognitionResultOptions, L_DocEnumOutputFileFormats, L_DocGetTextFormatInfo, L_DocSetSpecialChar, L_DocGetSpecialChar, L_DocGetRecognizedCharacters, L_DocSetRecognizedCharacters, L_DocFreeRecognizedCharacters, L_DocGetRecognizedWords, L_DocFreeRecognizedWords

Topics:

OCR Functions: Recognition

 

Recognizing Document Pages

Example

 L_INT DocSaveResultsToFileExample(L_HDOC hDoc, L_INT nPageIndex)
{
   L_INT nRet;
   RECOGNIZEOPTS RecogOpts;
   RecogOpts.uStructSize = sizeof(RECOGNIZEOPTS);
   RecogOpts.nPageIndexStart = nPageIndex;
   RecogOpts.nPagesCount = 1;
   RecogOpts.SpellLangId = LANG_ID_ENGLISH;
   RecogOpts.pszFileName = TEXT("c:\\testrdf.rdf");

   nRet = L_DocRecognize (hDoc, &RecogOpts, NULL, NULL);
   if (nRet == SUCCESS)
   {
      RESULTOPTIONS ResOpts;
      ZeroMemory(&ResOpts, sizeof(RESULTOPTIONS));
      nRet = L_DocGetRecognitionResultOptions(hDoc, &ResOpts, sizeof(RESULTOPTIONS));
      if(nRet != SUCCESS)
         return nRet;

      ResOpts.Format = DOC_RTF_WORD_2000;
      ResOpts.FormatLevel = FORMAT_LEVEL_FULL;
      ResOpts.DocOptions.PaperSize = SEL_PREDEFINED;
      ResOpts.DocOptions.PaperType = PAPER_TYPE_A4;
#if defined(LEADTOOLS_V16_OR_LATER)
      ResOpts.DocFormat = DOCUMENTFORMAT_USER;
#endif // #if defined(LEADTOOLS_V16_OR_LATER)

      nRet = L_DocSetRecognitionResultOptions(hDoc, &ResOpts);
      if(nRet != SUCCESS)
         return nRet;

      nRet = L_DocSaveResultsToFile(hDoc, TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\test.doc"));
      if (nRet == SUCCESS)
         MessageBox(NULL, TEXT("The recognition results were saved to a file."), TEXT("Notice!"), MB_OK);
      else
         return nRet;
   }
   else
      return nRet;

   return SUCCESS;
}