#include "ltdoc2.h"
L_LTDOC2_API L_INT L_Doc2CreateDocument(hDoc, pnDocId, nSid)
Creates a new document and adds it to the collection.
Handle to the OCR document.
Address of the variable to be updated with the newly created document ID.
Settings collection ID to be activated in the created document, created by calling L_Doc2CreateSettingsCollection.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
Begin recognizing documents by starting up the engine by calling L_Doc2StartUp. Next, create a settings collection ID by calling L_Doc2CreateSettingsCollection. Now call L_Doc2CreateDocument, which creates a unique document ID for each single document. All document processing is tied to this ID. The document Id created can be passed to the extended functions (L_Doc2XXXExt), such as L_Doc2AddPageExt, L_Doc2RecognizeExt, etc.
When document processing is complete, destroy the document ID by calling L_Doc2DestroyDocument which destroys the settings collection that activated this document. Then shut down the engine by calling L_Doc2ShutDown.
Required DLLs and Libraries
L_INT Doc2CreateDocumentExample(L_TCHAR* pszSettingFile)
{
L_INT nRet ;
L_HDOC2 hDoc = NULL;
L_INT nDocId = -1;
nRet = L_Doc2StartUp(&hDoc, NULL);
if (nRet != SUCCESS)
return nRet;
L_INT nSId;
L_Doc2CreateSettingsCollection(hDoc, -1, &nSId);
nRet = L_Doc2CreateDocument(hDoc, &nDocId, nSId);
if (nRet != SUCCESS)
{
L_Doc2ShutDown(&hDoc);
return nRet;
}
nRet = L_Doc2LoadSettingsExt(hDoc, nDocId, pszSettingFile);
if(nRet != SUCCESS)
{
L_Doc2ShutDown(&hDoc);
return nRet;
}
DOC2_FILLMETHOD fm;
nRet = L_Doc2GetFillMethodExt(hDoc, nDocId, &fm);
if (nRet == SUCCESS)
{
if (fm != DOC2_FILL_HANDPRINT)
{
nRet = L_Doc2SetFillMethodExt(hDoc, nDocId, DOC2_FILL_HANDPRINT);
if(nRet != SUCCESS)
{
L_Doc2ShutDown(&hDoc);
return nRet;
}
}
}
else
{
L_Doc2ShutDown(&hDoc);
return nRet;
}
nRet = L_Doc2SaveSettingsExt(hDoc, nDocId, pszSettingFile);
if (nRet == SUCCESS)
MessageBox(NULL, TEXT("The engine saved the updated settings to a file."), TEXT("Notice!"), MB_OK);
else
{
MessageBox(NULL, TEXT("The engine couldn't save the updated settings to a file."), TEXT("Error!"), MB_OK);
L_Doc2ShutDown(&hDoc);
return nRet;
}
//...
//...
//...
L_Doc2DestroyDocument(hDoc, nDocId);
nRet = L_Doc2ShutDown (&hDoc);
if(nRet != SUCCESS)
return nRet;
return SUCCESS;
}