Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.23
LEADTOOLS OCR C DLL Help

L_DocSetUserDictionary

Show in webframe

#include "ltdoc.h"

L_LTDOC_API L_INT L_DocSetUserDictionary(hDoc, pUDOpts , bCreateUD)

L_HDOC hDoc;

/* handle to the OCR document */

pUSERDICTIONARY pUDOpts;

/* pointer to USERDICTIONARY */

L_BOOL bCreateUD;

/* flag */

Sets the User dictionary and its default section for the checking subsystem.

Parameter

Description

hDoc

Handle to the OCR document.

pUDOpts

Pointer to a USERDICTIONARY structure which contains the user dictionary to be set.

bCreateUD

Flag to determine function behavior. Valid values as follows:

 

Value

Meaning

 

TRUE

Creates new user dictionary in memory

 

FALSE

Saves the current user dictionary into the file indicated in the pUDOpts parameter.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Specifies a User dictionary and its default section for the checking subsystem.

This function can also be used to initiate the creation of a new, empty User dictionary in memory.

To disable a previously enabled User dictionary, pass TRUE for bCreateUD when calling L_DocSetUserDictionary.

When creating a new, empty User dictionary, pass TRUE for bCreateUD.

If you save a user dictionary by calling this function with bCreateUD set to FALSE the user dictionary is saved to the file specified in pUDOpts. If you later want to set the user dictionary to use this file, call L_DocSetUserDictionary with the name of the file that contains the user dictionary set in the pUDOpts parameter of this function and pass FALSE for the bCreateUD parameter.

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_DocGetUserDictionary, L_DocGetUserDictionaryState, L_DocGetUserDictionarySection, L_DocGetUserDictionarySectionItem, L_DocAddItemToUserDictionary, L_DocRemoveItemFromUserDictionary

Topics:

OCR Functions: User Dictionary

 

Working with a Dictionary

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName


 L_INT DocSetUserDictionaryExample(L_HDOC hDoc)
{
   L_INT nRet;
   USERDICTIONARY UDict;

   UDict.uStructSize = sizeof(USERDICTIONARY);
   UDict.pszFileName = NULL;
   UDict.pszDefSection = NULL;

   // creates new user dictionary in memory
   nRet = L_DocSetUserDictionary(hDoc, &UDict, TRUE);
   if (nRet == SUCCESS)
   {
      L_CHAR * pszSectName = "cities";
      L_WCHAR * pwcItem1 = L"Peabody";
      L_WCHAR * pwcItem2 = L"Budapest";

      nRet = L_DocAddItemToUserDictionary(hDoc, pszSectName, pwcItem1, USER_DICT_LITERAL);
      if(nRet != SUCCESS)
         return nRet;
      nRet = L_DocAddItemToUserDictionary(hDoc, pszSectName, pwcItem2, USER_DICT_LITERAL);
      if(nRet != SUCCESS)
         return nRet;

      UDict.uStructSize = sizeof(USERDICTIONARY);
      UDict.pszFileName = MAKE_IMAGE_PATH(TEXT("USERDIC1.DIC"));
      UDict.pszDefSection = pszSectName;

      nRet = L_DocSetUserDictionary(hDoc, &UDict, FALSE);
      if(nRet != SUCCESS)
         return nRet;
      if (nRet == SUCCESS)
         MessageBox(NULL, TEXT("The user dictionary is saved into a file."), TEXT("Notice!"), MB_OK);
      else
         return nRet;
   }
   else 
      return nRet;
   return SUCCESS;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.