L_Doc2SaveResultsToFile

#include "ltdoc2.h"

L_LTDOC2_API L_INT EXT_FUNCTION L_Doc2SaveResultsToFile(hDoc, pszFileName)

Saves the recognition results to a file.

Parameters

L_HDOC2 hDoc

Handle to the OCR document.

L_TCHAR * pszFileName

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

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

To recognize one or more pages, call the L_Doc2Recognize / L_Doc2RecognizeExt function.

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

Get the current save recognition results options by calling L_Doc2GetRecognitionResultOptions / L_Doc2GetRecognitionResultOptionsExt.

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

Get the format options by calling L_Doc2GetOutputFormatSettings / L_Doc2GetOutputFormatSettingsExt, and to update the format options, call the L_Doc2SetOutputFormatSettings / L_Doc2SetOutputFormatSettingsExt function.

Use L_Doc2SaveResultsToFile2 to save the recognition results to different formats using the same recognition results and at the same time maintain quality. However, it consumes more memory than L_Doc2SaveResultsToFile / L_Doc2SaveResultsToFileExt.

If memory is a constraint, use L_Doc2SaveResultsToFile / L_Doc2SaveResultsToFileExt instead. However, note that **L_Doc2SaveResultsToFile / L_Doc2SaveResultsToFileExt requires OCR to be performed separately for each file format in order to maintain quality.

The difference between L_Doc2SaveResultsToFile and L_Doc2SaveResultsToFileExt is that L_Doc2SaveResultsToFileExt includes the document ID parameter (nDocId).

Required DLLs and Libraries

See Also

Functions

Topics

Example

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, MAKE_IMAGE_PATH(TEXT("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; 
} 
Help Version 20.0.2020.4.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS OCR Module - OmniPage Engine C API Help