L_DocAddZone

#include "ltdoc.h"

L_INT EXT_FUNCTION L_DocAddZone(hDoc, nPageIndex, nZoneIndex, pZoneData)

L_HDOC hDoc;

/* handle to the OCR document */

L_INT nPageIndex;

/* page index */

L_INT nZoneIndex;

/* index of the zone to be added */

pZONEDATA pZoneData;

/* pointer to a ZONEDATA structure */

Adds new zone in the zone list of the specified page.

Parameter

Description

hDoc

Handle to the OCR document.

nPageIndex

Index of the page on which to add the zone. This is a zero-based index.

nZoneIndex

Position in the list of zones at which to add new zone. Use -1 to append the page to the end of the list. This is a zero-based index.

pZoneData

Pointer to a ZONEDATA structure which contains the zone data to be added.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Adds a new zone in the zone list of the specified page. After the zone is added, the zone list is recalculated automatically.

When adding a zone, the application should directly initialize the following members of the ZONEDATA structure, since these members will not take their default values:

uStructSize
rcArea
FillMethod
CharFilter
Type
RecogModule

The OCR engine manages the ID member of the ZONEDATA structure.

The Type member of the ZONEDATA structure should be one of the following values:

ZONE_FLOWTEXT

ZONE_TABLE

ZONE_GRAPHIC

For successful zone addition, the whole zone area must lie within the page area and the top left coordinates of the zone must have lower values than those of the bottom right ones.

To find all zones in a specific page, use L_DocFindZones.

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_DocGetZoneCount, L_DocGetZone, L_DocUpdateZone, L_DocRemoveZone, L_DocImportZones, L_DocExportZones, L_DocFindZones, L_DocSetZoneOptions, L_DocGetZoneOptions

Topics:

OCR Functions: Zones

 

Working with Zones

Example

L_INT EXT_CALLBACK VerificationCB(L_INT nZoneIndex, L_TCHAR L_FAR * pszWord, VERIFYCODE * pVerify,L_VOID L_FAR * pUserData)
{
   //...
   //... Set your code here
   //...
   return SUCCESS;
}

void TestAddZones(L_HDOC hDoc, L_INT nPageIndex)
{
   ZONEDATA ZoneData;
   L_INT nZoneCount = 0;
   L_TCHAR szBuffer[100];

   memset(szBuffer, 0, sizeof(szBuffer));
   memset(&ZoneData, 0, sizeof(ZONEDATA));

   ZoneData.uStructSize = sizeof(ZONEDATA);
   ZoneData.rcArea.left = 100;
   ZoneData.rcArea.top = 100;
   ZoneData.rcArea.right = 200;
   ZoneData.rcArea.bottom = 200;
   ZoneData.FillMethod = FILL_DEFAULT;
   ZoneData.RecogModule = RECOGMODULE_AUTO;
   ZoneData.CharFilter = ZONE_CHAR_FILTER_DEFAULT;
   ZoneData.Type = ZONE_FLOWTEXT;
   ZoneData.uFlags = 0;
   ZoneData.pfnCallback = VerificationCB;
   ZoneData.pUserData = NULL;

   L_INT nRet = L_DocAddZone(hDoc, nPageIndex, 0, &ZoneData);
   if (nRet == SUCCESS)
      MessageBox(NULL, TEXT("The specified zone is added."), TEXT("Notice!"), MB_OK);

   nRet = L_DocGetZoneCount (hDoc, nPageIndex, &nZoneCount);
   if (nRet != SUCCESS)
      MessageBox(NULL, TEXT("An error occurred during L_DocGetZoneCount"), TEXT("Error!"), MB_OK);
   else
   {
      wsprintf(szBuffer, TEXT("Total zones in the specified page = %d\n"), nZoneCount);
      MessageBox(NULL, szBuffer, TEXT("Zone Count!"), MB_OK);
   }