Quickly saves the given page as an SVG file.
#include "ltocr.h"
L_LTOCR_API L_INT L_OcrPage_SaveSvg(page, fileName)
Handle to the OCR page.
The name of the output file to which to save the SVG data.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
This function will save the recognition result of this L_OcrPage as SVG. Normally, the L_OcrDocument_Save must be used to save a page (or more) to an output format. For SVG format, use this function to quickly save the page and create the output document without having to create an OCR document handle first.
This function works whether the page is part of an OCR document or is standalone.
To quickly save a given page as an SVG stream, call L_OcrPage_SaveSvgMemory.
For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.
Functions:
L_INT L_OcrPage_SaveSvgExample()
{
L_INT retCode = SUCCESS;
BITMAPHANDLE bitmap = { 0 };
L_OcrEngine ocrEngine = NULL;
L_OcrPage ocrPage = NULL;
// Create an instance of the engine
retCode = L_OcrEngineManager_CreateEngine(L_OcrEngineType_LEAD, &ocrEngine);
if (retCode != SUCCESS)
goto CLEANUP;
// Start the engine using default parameters
retCode = L_OcrEngine_Startup(ocrEngine, NULL, OCR_LEAD_RUNTIME_DIR);
if (retCode != SUCCESS)
goto CLEANUP;
// Load an image to process
retCode = L_LoadBitmap(MAKE_IMAGE_PATH(L_TEXT("Ocr1.tif")), &bitmap, sizeof(BITMAPHANDLE), 0, ORDER_RGB, NULL, NULL);
if (retCode != SUCCESS)
goto CLEANUP;
// Add the image to an OCR page
retCode = L_OcrPage_FromBitmap(ocrEngine, &ocrPage, &bitmap, L_OcrBitmapSharingMode_AutoFree, NULL, NULL);
if (retCode != SUCCESS)
goto CLEANUP;
// Transfer ownership to the OCR page
memset(&bitmap, 0, sizeof(bitmap));
// Recognize it
retCode = L_OcrPage_Recognize(ocrPage, NULL, NULL);
if (retCode != SUCCESS)
goto CLEANUP;
// Save the results directly to a file
retCode = L_OcrPage_SaveSvg(ocrPage, MAKE_IMAGE_PATH(L_TEXT("Ocr1.pdf")));
CLEANUP:
if (bitmap.Flags.Allocated)
L_FreeBitmap(&bitmap);
if (ocrPage != NULL)
L_OcrPage_Destroy(ocrPage);
if (ocrEngine != NULL)
L_OcrEngine_Destroy(ocrEngine);
return retCode;
}