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_Doc2SetUserDictionary

Show in webframe

#include "ltdoc2.h"

L_LTDOC2_API L_INT EXT_FUNCTION L_Doc2SetUserDictionary(hDoc, pUDOpts, bCreateUD)

L_HDOC2 hDoc;

/* handle to the OCR document */

pUSERDICTIONARY2 pUDOpts;

/* pointer to USERDICTIONARY2 */

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 the USERDICTIONARY2 structure, which contains the User dictionary to be set.

bCreateUD

Flag that determines function behavior. Possible values are:

 

Value

Meaning

 

TRUE

Create a new dictionary or disable an existing one.

 

FALSE

Set the User dictionary to use the dictionary set in the pUDOpts parameter.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function specifies a User dictionary and its default section for the checking subsystem.

This function can also be used to create a new, empty User dictionary in memory.

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

To create 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. To set the User dictionary to use a file, call the L_Doc2SetUserDictionary function 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

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_Doc2GetUserDictionary, L_Doc2GetUserDictionaryState, L_Doc2GetUserDictionarySection, L_Doc2GetUserDictionarySectionItem, L_Doc2AddItemToUserDictionary, L_Doc2RemoveItemFromUserDictionary

Topics:

OCR Functions: User Dictionary

 

Working with a Dictionary

Example

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


L_LTDOC2TEX_API  L_INT Doc2SetUserDictionaryExample(L_HDOC2 hDoc)
{
   L_INT nRet;
   USERDICTIONARY2 UDict;

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

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

      nRet = L_Doc2AddItemToUserDictionary(hDoc, pszSectName, pwcItem1, DOC2_USER_DICT_LITERAL);
      if(nRet != SUCCESS)
         return nRet;
      nRet = L_Doc2AddItemToUserDictionary(hDoc, pszSectName, pwcItem2, DOC2_USER_DICT_LITERAL);
      if(nRet != SUCCESS)
         return nRet;

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

      nRet = L_Doc2SetUserDictionary(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.