L_Doc2SaveResultsToFile

#include "ltdoc2.h"

L_LTDOC2_API L_INT EXT_FUNCTION L_Doc2SaveResultsToFile(hDoc, pszFileName)

L_HDOC2 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 the L_Doc2Recognize function.

To set save recognition results options, call the L_Doc2SetRecognitionResultOptions function.

To get the current save recognition results options, call the L_Doc2GetRecognitionResultOptions function.

To get all supported output formats, call the L_Doc2EnumOutputFileFormats function.

To get the format options, call the L_Doc2GetOutputFormatSettings function, and to update the format options, call the L_Doc2SetOutputFormatSettings function.

Use L_Doc2SaveResultsToFile2 when you want to save the recognition results to different formats using the same recognition results while maintaining quality. Use L_Doc2SaveResultsToFile when memory is a constraint (it uses less memory than L_Doc2SaveResultsToFile2). However, L_Doc2SaveResultsToFile requires OCR to be performed separately for each file format in order to maintain quality.

Required DLLs and Libraries

LTDOC2

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_Doc2GetStatus, L_Doc2Recognize, L_Doc2SetRecognitionResultOptions, L_Doc2GetRecognitionResultOptions, L_Doc2EnumOutputFileFormats, L_Doc2GetTextFormatInfo, L_Doc2SetSpecialChar, L_Doc2GetSpecialChar, L_Doc2GetRecognizedCharacters, L_Doc2SetRecognizedCharacters, L_Doc2FreeRecognizedCharacters, L_Doc2GetRecognizedWords, L_Doc2FreeRecognizedWords, L_Doc2GetRecognizedCharactersColors, L_Doc2SetOutputFormatSettings, L_Doc2GetOutputFormatSettings, L_Doc2SaveResultsToFile2

Topics:

OCR Functions: Recognition

 

Recognizing Document Pages

Example

L_LTDOC2TEX_API  L_INT Doc2SaveResultsToFileExample(L_HDOC2 hDoc, L_INT nPageIndex)
{
   L_INT nRet;
   RECOGNIZEOPTS2 RecogOpts;
   RecogOpts.uStructSize = sizeof(RECOGNIZEOPTS2);
   RecogOpts.nPageIndexStart = nPageIndex;
   RecogOpts.nPagesCount = 1;
   RecogOpts.SpellLangId = DOC2_LANG_ID_ENGLISH;

   nRet = L_Doc2Recognize (hDoc, &RecogOpts, NULL, NULL);
   if (nRet == SUCCESS)
   {
      RESULTOPTIONS2 ResOpts;
      ZeroMemory(&ResOpts, sizeof(RESULTOPTIONS2));
      nRet = L_Doc2GetRecognitionResultOptions(hDoc, &ResOpts, sizeof(RESULTOPTIONS2));
      if(nRet != SUCCESS)
         return nRet;

      ResOpts.Format = DOC2_WORD_2000;
      ResOpts.FormatLevel = DOC2_FORMAT_LEVEL_AUTO;
      ResOpts.DocFormat = DOCUMENTFORMAT_USER;

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

      nRet = L_Doc2SaveResultsToFile(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;
}