#include "l_bitmap.h"
L_LTDOC2_API L_INT EXT_FUNCTION L_Doc2SaveResultsToFile2(hDoc, pszFileName, uFlags)
Saves the recognition results to a file.
Handle to the OCR document.
Character string containing the name of the output file to be saved.
Flags that determine function behavior. Possible values are:
Value | Meaning |
---|---|
0 | The default behavior. It works the same way L_Doc2SaveResultsToFile works. |
DOC2_SAVE_PAGE_RESULTS | [0x001] Saves all page(s) results before saving it to final results. |
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
To recognize one or more pages, call the L_Doc2Recognize function.
To set save recognition results options, call the L_Doc2SetRecognitionResultOptions function.
Get the current save recognition results options by calling L_Doc2GetRecognitionResultOptions.
To get all supported output formats, call the L_Doc2EnumOutputFileFormats function.
To get the format options, call the L_Doc2GetOutputFormatSettings function, and to update the format options, call L_Doc2SetOutputFormatSettings.
Use L_Doc2SaveResultsToFile2 to save the recognition results to different formats using the same recognition results and at the same time maintain quality. However, it consumes more memory than L_Doc2SaveResultsToFile / L_Doc2SaveResultsToFileExt.
If memory is a constraint, use L_Doc2SaveResultsToFile / L_Doc2SaveResultsToFileExt instead. However, note that L_Doc2SaveResultsToFile / L_Doc2SaveResultsToFileExt requires OCR to be performed separately for each file format in order to maintain quality.
The difference between L_Doc2SaveResultsToFile and L_Doc2SaveResultsToFileExt is that L_Doc2SaveResultsToFileExt includes the document ID parameter (nDocId).
Required DLLs and Libraries
L_INT Doc2SaveResultsToFile2Example(L_HDOC2 hDoc, L_INT nPageIndex)
{
L_INT nRet;
RECOGNIZEOPTS2 RecogOpts;
RecogOpts.uStructSize = sizeof(RECOGNIZEOPTS2);
RecogOpts.nPageIndexStart = nPageIndex;
RecogOpts.nPagesCount = 1;
RecogOpts.SpellLangId = DOC2_LANG_ID_ENGLISH;
nRet = L_Doc2Recognize (hDoc, &RecogOpts, NULL, NULL);
if (nRet == SUCCESS)
{
RESULTOPTIONS2 ResOpts;
ZeroMemory(&ResOpts, sizeof(RESULTOPTIONS2));
nRet = L_Doc2GetRecognitionResultOptions(hDoc, &ResOpts, sizeof(RESULTOPTIONS2));
if(nRet != SUCCESS)
return nRet;
ResOpts.DocFormat = DOCUMENTFORMAT_PDF;
nRet = L_Doc2SetRecognitionResultOptions(hDoc, &ResOpts);
if(nRet != SUCCESS)
return nRet;
DOCWRTPDFOPTIONS PdfOptions;
memset(&PdfOptions, 0, sizeof(DOCWRTPDFOPTIONS));
PdfOptions.bImageOverText = TRUE;
PdfOptions.PdfProfile = DOCWRTPDFPROFILE_PDF;
L_Doc2SetDocumentWriterOptions(hDoc, &PdfOptions, sizeof(DOCWRTPDFOPTIONS));
nRet = L_Doc2SaveResultsToFile2(hDoc, MAKE_IMAGE_PATH(TEXT("Test_PDF.pdf")), DOC2_SAVE_PAGE_RESULTS);
if (nRet == SUCCESS)
MessageBox(NULL, TEXT("The recognition results were saved to a file."), TEXT("Notice!"), MB_OK);
else
return nRet;
L_Doc2GetDocumentWriterOptions(hDoc, &PdfOptions, sizeof(DOCWRTPDFOPTIONS));
PdfOptions.PdfProfile = DOCWRTPDFPROFILE_PDFA;
L_Doc2SetDocumentWriterOptions(hDoc, &PdfOptions, sizeof(DOCWRTPDFOPTIONS));
nRet = L_Doc2SaveResultsToFile2(hDoc, MAKE_IMAGE_PATH(TEXT("Test_PDFA.pdf")), DOC2_SAVE_PAGE_RESULTS);
if (nRet == SUCCESS)
MessageBox(NULL, TEXT("The recognition results were saved to a file."), TEXT("Notice!"), MB_OK);
else
return nRet;
}
else
return nRet;
return SUCCESS;
}