LEADTOOLS Support
Document
Document SDK Examples
Loading some pages from the middle of a multi-page file
This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Wednesday, June 28, 2006 11:11:18 AM(UTC)
Groups: Manager, Tech Support
Posts: 367
Was thanked: 1 time(s) in 1 post(s)
The code below loads pages 3, 4 and 5 from a multipage file (such as TIFF or PDF) without loading all the pages. The idea is to begin at the desired page, then abort when needed pages are loaded.
This code uses LEADTOOLS 14 DLL API.
#include "l_bitmap.h"
int nCountLoadPage = 0;
L_INT __stdcall LoadCallBack(pFILEINFO finfo, pBITMAPHANDLE pBmp, pLEADFILEREADDATA FileReadData, L_UINT uFlags, L_INT nRow, L_INT nLines, L_VOID L_FAR * pUserData)
{
if(nCountLoadPage >= 3)
return ERROR_NORMAL_ABORT;
if((uFlags & FILEREAD_LASTROW) && (uFlags & FILEREAD_LASTPASS))
{
// can do something like L_InsertBitmapListItem(m_hList, (L_UINT)-1, pBmp);
nCountLoadPage++;
}
return SUCCESS;
}
void LoadSomePages()
{
BITMAPHANDLE bmp={0};
LOADFILEOPTION LoadFileOption={0};
L_GetDefaultLoadFileOption(&LoadFileOption, sizeof(LOADFILEOPTION));
LoadFileOption.PageNumber = 3; //first page is 1, second is 2 and so on.
bmp.uStructSize = sizeof(BITMAPHANDLE);
nCountLoadPage = 0;
L_LoadFile("MulPage.TIF",
&bmp, sizeof(BITMAPHANDLE),
0,
ORDER_BGRORGRAY,
LOADFILE_ALLOCATE | LOADFILE_STORE | LOADFILE_ALLPAGES,
LoadCallBack,
NULL,
&LoadFileOption, NULL);
}
Amin Dodin
Senior Support Engineer
LEAD Technologies, Inc.
#2
Posted
:
Monday, July 31, 2006 11:53:05 PM(UTC)
Groups: Registered
Posts: 10
I want to load some or all pages and want to do ocr on it. I want to do this programmatically (i.e. in loop). pls provide me the code for this in Dot Net Version (c#).
thanks
neeraj kaushik
#3
Posted
:
Thursday, August 3, 2006 1:24:38 AM(UTC)
Groups: Registered, Tech Support
Posts: 1,326
Was thanked: 1 time(s) in 1 post(s)
Hello,
You can load and OCR Multi-Page TIFF images by using the following code:
+-----------------------+
//******* OCR Initialization ********//
RasterCodecs codecs = new RasterCodecs();
Leadtools.Ocr.RasterOcrResultOptions resOpts = new Leadtools.Ocr.RasterOcrResultOptions();
RasterSupport.Unlock(RasterSupportType.Ocr,"OCR Unlock Key");
ocr = new Leadtools.Ocr.RasterOcr();
rasterOcrZoneData = new Leadtools.Ocr.RasterOcrZoneData();
//******** OCR Startup *************//
ocr.StartUp();
//******** Add Page ****************//
using (IRasterImage rasterImage = codecs.Load(@"D:\20060984959.tif"))
{
ocr.EnableSubSystem = true;
ocr.EnableCorrection = true;
ocr.SpellLanguageID = RasterOcrLanguage.Auto;
ocr.RecognitionDataFileName = @"c:\ocrocr1234.rdf";
for (int i = 0;i<rasterImage.PageCount -1;i++)
{
rasterImage.Page = i+1;
ocr.AddPage(rasterImage, -1);
}
MessageBox.Show(ocr.PageCount.ToString());
try
{
ocr.Recognize(0, ocr.PageCount -1 );
resOpts = ocr.SaveResultOptions;
resOpts.Format = Leadtools.Ocr.RasterOcrFormatType.Rtf;
resOpts.FormatLevel = Leadtools.Ocr.RasterOcrFormatLevel.Part;
ocr.SaveResultOptions = resOpts;
ocr.SaveResultsToFile(@"c:\20060984959.rtf");
}
catch(Exception er)
{
MessageBox.Show(er.Message.ToString());
}
ocr.ShutDown();
+-----------------------+
Thanks,
Maen Badwan
LEADTOOLS Technical Support
LEADTOOLS Support
Document
Document SDK Examples
Loading some pages from the middle of a multi-page file
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.