L_Doc2AddZone

#include "ltdoc2.h"

L_LTDOC2_API L_INT EXT_FUNCTION L_Doc2AddZone(hDoc, nPageIndex, nZoneIndex, pZoneData)

L_HDOC2 hDoc;

/* handle to the OCR document */

L_INT nPageIndex;

/* page index */

L_INT nZoneIndex;

/* index of the zone to be added */

pZONEDATA2 pZoneData;

/* pointer to a ZONEDATA2 structure */

Adds a new zone to the zone list for 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 ZONEDATA2 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 to the zone list for 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 ZONEDATA2 structure, since these members will not take default values:

uStructSize
rcArea
FillMethod
CharFilter
Type
RecogModule

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

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

DOC2_ZONE_FLOWTEXT

DOC2_ZONE_TABLE

DOC2_ZONE_GRAPHIC

DOC2_ZONE_AUTO

For successful zone addition:

To find all zones in a specific page, use the L_Doc2FindZones function.

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_Doc2GetZoneCount, L_Doc2GetZone, L_Doc2UpdateZone, L_Doc2RemoveZone, L_Doc2ImportZones, L_Doc2ExportZones, L_Doc2FindZones, L_Doc2SetZoneOptions, L_Doc2GetZoneOptions, VERIFICATIONCALLBACK2

Topics:

OCR Functions: Zones

 

Working with Zones

Example

L_INT EXT_CALLBACK VerificationCB(L_INT nZoneIndex,
                                  L_TCHAR* pszWord,
                                  DOC2_VERIFYCODE* pVerify,
                                  L_VOID* pUserData)
{
   UNREFERENCED_PARAMETER(nZoneIndex);
   UNREFERENCED_PARAMETER(pszWord);
   UNREFERENCED_PARAMETER(pVerify);
   UNREFERENCED_PARAMETER(pUserData);

   //...
   //... Set your code here
   //...
   return SUCCESS;
}

L_LTDOC2TEX_API  L_INT Doc2AddZoneExample(L_HDOC2 hDoc, L_INT nPageIndex)
{
   L_INT nRet;
   ZONEDATA2 ZoneData;
   L_INT nZoneCount = 0;
   L_TCHAR szBuffer[100];

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

   ZoneData.uStructSize = sizeof(ZONEDATA2);
   ZoneData.rcArea.left = 100;
   ZoneData.rcArea.top = 100;
   ZoneData.rcArea.right = 200;
   ZoneData.rcArea.bottom = 200;
   ZoneData.FillMethod = DOC2_FILL_DEFAULT;
   ZoneData.RecogModule = DOC2_RECOGMODULE_AUTO;
   ZoneData.CharFilter = DOC2_ZONE_CHAR_FILTER_DEFAULT;
   ZoneData.Type = DOC2_ZONE_FLOWTEXT;
   ZoneData.uFlags = 0;
   ZoneData.pfnCallback = VerificationCB;
   ZoneData.pUserData = NULL;

   nRet = L_Doc2AddZone(hDoc, nPageIndex, 0, &ZoneData);
   if (nRet == SUCCESS)
      MessageBox(NULL, TEXT("The specified zone is added."), TEXT("Notice!"), MB_OK);
   else
      return nRet;
   nRet = L_Doc2GetZoneCount (hDoc, nPageIndex, &nZoneCount);
   if (nRet != SUCCESS)
   {
      MessageBox(NULL, TEXT("An error occurred during L_Doc2GetZoneCount"), TEXT("Error!"), MB_OK);
      return nRet;
   }
   else
   {
      wsprintf(szBuffer, TEXT("Total zones in the specified page = %d\n"), nZoneCount);
      MessageBox(NULL, szBuffer, TEXT("Zone Count!"), MB_OK);
   }

   L_INT nUserZoneCount=0;
   nRet = L_Doc2GetZoneCount(hDoc, nPageIndex, &nUserZoneCount);
   if (nRet != SUCCESS)
      return nRet;

   wsprintf(szBuffer, TEXT("Total zones in the specified page = %d\n"), nUserZoneCount);
   MessageBox(NULL, szBuffer, TEXT("Zone Count!"), MB_OK);
   return SUCCESS;
}