Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

Re: Text file loading is taking long time...Please help!!!
Started by Ganesh at 06-27-2008 6:28. Topic has 12 replies.

Print Search « Previous Thread Next Thread »
  06-27-2008, 6:28
Ganesh is not online. Last active: 1/7/2009 7:58:36 AM Ganesh

Top 150 Posts
Joined on 01-08-2008
Posts 21
Text file loading is taking long time...Please help!!!
Reply Quote
Hi,

I am using below code to convert text file content into tiff image. Loading command is taking lot of time to load the file. Is there anyway to improve this performance. Please advice its urgent!!!

Herewith I have attached text file which I used for testing. Please find


Code:
-----

string _loadFile = @"C:\LeadTools.txt";
RasterCodecs _codecs = new RasterCodecs();

_codecs.Options.Txt.Load.Enabled = true;

_codecs.Options.Txt.Load.TopMargin = 1;

_codecs.Options.Txt.Load.BottomMargin = 1;

_codecs.Options.Txt.Load.LeftMargin = 1;

_codecs.Options.Txt.Load.RightMargin = 1;

_codecs.Options.Txt.Load.FontColor = new Leadtools.RasterColor(System.Drawing.Color.Black);

_codecs.Options.Txt.Load.FontSize = 12;

_codecs.Options.Txt.Load.Bold = false;

using (Leadtools.IRasterImage image = _codecs.Load(_loadFile))
{

string filename = "";

Leadtools.RasterImageFormat format = Leadtools.RasterImageFormat.TifCcittGroup4;

int bpp = 1;

int firstPage = 1;

int lastPage = image.PageCount;

int firstSavePageNumber = 1;


Leadtools.Codecs.CodecsSavePageMode pageMode = Leadtools.Codecs.CodecsSavePageMode.Append;


for (int i = 1; i <= lastPage; i++)
{
filename = @"C:\Tiff_Images\img"+i.ToString()+".tif";
_codecs.Save(image, filename, format, bpp,

i, i, i,

pageMode);
}
}


It will be greatly helpful if you can provide some sample code to improve the performance.


Note: I am using Leadtools version 14.5.0.68 and C# 2008.

Thanks,

Ganesh.
   Report 
  06-27-2008, 10:34
jigar is not online. Last active: 12/12/2008 5:08:42 PM jigar



Top 10 Posts
Joined on 08-22-2007
Posts 480
Re: Text file loading is taking long time...Please help!!!
Reply Quote
Hi Ganesh,

For some reason the TXT file didn't get attached.  How big is the text file?  Try setting the _codecs.Options.Load.XResolution and _codecs.Options.Load.YResolution to 150, and then 300 to see how long the loading times are.

How many pages does the TXT file have?  Call _codecs.GetInformation() before calling _codecs.Load() to find out how many total pages there are.

LEADTOOLS Technical Support
   Report 
  06-30-2008, 0:48
Ganesh is not online. Last active: 1/7/2009 7:58:36 AM Ganesh

Top 150 Posts
Joined on 01-08-2008
Posts 21
Re: Text file loading is taking long time...Please help!!!
Reply Quote
Hi,

Thank you very much for your reply.

Text file size is 3MB. I tried calling _codecs.GeInformation() before calling _Codecs.load(). It seems, text file contains 2000+ pages.

Could you please provide some way to improve the file load performance.

Thanks

Ganesh.
   Report 
  06-30-2008, 10:35
jigar is not online. Last active: 12/12/2008 5:08:42 PM jigar



Top 10 Posts
Joined on 08-22-2007
Posts 480
Re: Text file loading is taking long time...Please help!!!
Reply Quote
Loading TXT files is a CPU intensive process because TXT files are vector files and they have no explicit page separators.  So you can load a certain number of pages at a time.  You can specify the first and last page parameters of the codecs.Load() method.  You can load pages 1-10, 11-20, etc., in blocks.  See how that works out for you.

LEADTOOLS Technical Support
   Report 
  07-01-2008, 9:59
Ganesh is not online. Last active: 1/7/2009 7:58:36 AM Ganesh

Top 150 Posts
Joined on 01-08-2008
Posts 21
Re: Text file loading is taking long time...Please help!!!
Reply Quote
Hi,

Thanks for your response.

Is it possible to get a stream for a particular page or is it possible to identify how many lines we can print for each page(including wordwrap)?

If you have any sample code to acheive the above please send.

Thanks,

Ganesh.


   Report 
  07-01-2008, 10:11
Ganesh is not online. Last active: 1/7/2009 7:58:36 AM Ganesh

Top 150 Posts
Joined on 01-08-2008
Posts 21
Re: Text file loading is taking long time...Please help!!!
Reply Quote
What I mean is, to get the content of the each page.

Regards

Ganesh.
   Report 
  07-01-2008, 12:07
jigar is not online. Last active: 12/12/2008 5:08:42 PM jigar



Top 10 Posts
Joined on 08-22-2007
Posts 480
Re: Text file loading is taking long time...Please help!!!
Reply Quote
You can calculate it to an approximate value.  Knowing the dpi and font size of the image, as well as the page margins, you can calculate how many characters you can fit in one page.

Have you tried loading one page at a time?  Like: RasterCodecs.Load("file.txt", 0, CodecsLoadByteOrder.BgrOrGray, 1, 1).  The last two parameters are equal and you increment them by 1 for each page.

LEADTOOLS Technical Support
   Report 
  07-02-2008, 10:17
Ganesh is not online. Last active: 1/7/2009 7:58:36 AM Ganesh

Top 150 Posts
Joined on 01-08-2008
Posts 21
Re: Text file loading is taking long time...Please help!!!
Reply Quote
Thanks.

I tried loading single page(as you suggessted) and save them, for 1hour it just converted only 29pages only...


Could you please give some sample to calcuate the content per page based on the below code...

_codecs.Options.Txt.Load.Enabled = true;
_codecs.Options.Txt.Load.TopMargin = 1;
_codecs.Options.Txt.Load.BottomMargin = 1;
_codecs.Options.Txt.Load.LeftMargin = 1;
_codecs.Options.Txt.Load.RightMargin = 1;
_codecs.Options.Txt.Load.Bold = false;
_codecs.Options.Txt.Load.FaceName = "Arial";
_codecs.Options.Txt.Load.FontSize = 10;
_codecs.Options.Txt.Load.FontColor = new RasterColor(System.Drawing.Color.Black);
_codecs.Options.Load.XResolution = 150;
_codecs.Options.Load.YResolution = 300;

because some of the line in the text file are longer one so while converting image it coming as 2lines(word warp) sometime morethan 3times...

It will be greatly helpful if you can provide some sample.


Also I am getting one error message while loading
text(even 2kb) file...

Error Message:
---------------
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."


StackTrace:
------------

at a(UInt32 )\r\n at a(Stream , i , ICI_PUT_EXTRA )\r\n at a(Stream , i , ICI_PUT_EXTRA , LOADFILEOPTION )\r\n at a(INFODISPATCH )\r\n at Leadtools.Kernel.Codecs.Codec.fltInfo(Object pDispatch)\r\n at Leadtools.Kernel.Codecs.KernelCodecs.a(String , FILEINFO , UInt32 , INFOLOADSTATE , Object , Object , LOADFILEOPTION , LOADDISPATCH )\r\n at Leadtools.Kernel.Codecs.KernelCodecs.a(String , BitmapHandle , UInt32 , WinRect& , Int32 , Int32 , UInt32 , FILEREADCALLBACK , Object , UInt32 , INFOLOADSTATE , LOADFILEOPTION , FILEINFO , LOADCUSTOMFILEOPTION , LOADCUSTOMFILECALLBACK , Object , Int32 , LAYERINFO[] )\r\n at Leadtools.Kernel.Codecs.KernelCodecs.a(String , BitmapHandle , UInt32 , WinRect& , Int32 , Int32 , UInt32 , FILEREADCALLBACK , Object , UInt32 , LOADFILEOPTION , FILEINFO , LOADCUSTOMFILEOPTION , LOADCUSTOMFILECALLBACK , Object , Int32 , LAYERINFO[] )\r\n at Leadtools.Kernel.Codecs.KernelCodecs.L_LoadFile(String pszFile, BitmapHandle pBitmap, UInt32 uStructSize, Int32 nBitsPerPixel, In
t32 nOrder, UInt32 uFlags, FILEREADCALLBACK pfnCallback, Object pUserData, LOADFILEOPTION pLoadOptions, FILEINFO pFileInfo)\r\n at Leadtools.Codecs.RasterCodecs.a(BitmapHandle A_0, b A_1)\r\n at Leadtools.Codecs.RasterCodecs.a(b A_0)\r\n at Leadtools.Codecs.RasterCodecs.Load(String fileName, Int32 bitsPerPixel, CodecsLoadByteOrder order, Int32 firstPage, Int32 lastPage)\r\n


Thanks,

Ganesh.
   Report 
  07-03-2008, 17:46
jigar is not online. Last active: 12/12/2008 5:08:42 PM jigar



Top 10 Posts
Joined on 08-22-2007
Posts 480
Re: Text file loading is taking long time...Please help!!!
Reply Quote
What build version is your Leadtools.Codecs.Txt.dll file?  I'm trying load a simple 4 byte text file and it's throwing a null reference error for me with default settings.  I'm running 14.5.0.77.  Also zip up the 2kb file that fails on you and attached it to your post.  I want to try that one out too.

LEADTOOLS Technical Support
   Report 
  07-04-2008, 9:56
Ganesh is not online. Last active: 1/7/2009 7:58:36 AM Ganesh

Top 150 Posts
Joined on 01-08-2008
Posts 21
Re: Text file loading is taking long time...Please help!!!

Attachment: testTxt.txt
Reply Quote
Hi

I am using 14.5.0.68 version. May be I think you need to use the below line

RasterCodecs.CodecsPath = System.IO.Path.Combine(Environment.CurrentDirectory, @"Codecs");
_codecs = new RasterCodecs();



Regards,

Ganesh.
   Report 
  07-07-2008, 9:20
Ganesh is not online. Last active: 1/7/2009 7:58:36 AM Ganesh

Top 150 Posts
Joined on 01-08-2008
Posts 21
Re: Text file loading is taking long time...Please help!!!
Reply Quote
Hi,

Could you please tell me why I am keep on getting the below message and how to fix this issue. I am using Leadtools.Codecs.Txt.dll version : 14.5.0.68.
Its urgent!!!

Error Message:
---------------
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."


StackTrace:
------------

at a(UInt32 )\r\n at a(Stream , i , ICI_PUT_EXTRA )\r\n at a(Stream , i , ICI_PUT_EXTRA , LOADFILEOPTION )\r\n at a(INFODISPATCH )\r\n at Leadtools.Kernel.Codecs.Codec.fltInfo(Object pDispatch)\r\n at Leadtools.Kernel.Codecs.KernelCodecs.a(String , FILEINFO , UInt32 , INFOLOADSTATE , Object , Object , LOADFILEOPTION , LOADDISPATCH )\r\n at Leadtools.Kernel.Codecs.KernelCodecs.a(String , BitmapHandle , UInt32 , WinRect& , Int32 , Int32 , UInt32 , FILEREADCALLBACK , Object , UInt32 , INFOLOADSTATE , LOADFILEOPTION , FILEINFO , LOADCUSTOMFILEOPTION , LOADCUSTOMFILECALLBACK , Object , Int32 , LAYERINFO[] )\r\n at Leadtools.Kernel.Codecs.KernelCodecs.a(String , BitmapHandle , UInt32 , WinRect& , Int32 , Int32 , UInt32 , FILEREADCALLBACK , Object , UInt32 , LOADFILEOPTION , FILEINFO , LOADCUSTOMFILEOPTION , LOADCUSTOMFILECALLBACK , Object , Int32 , LAYERINFO[] )\r\n at Leadtools.Kernel.Codecs.KernelCodecs.L_LoadFile(String pszFile, BitmapHandle pBitmap, UInt32 uStructSize, Int32 nBitsPerPixel, In
t32 nOrder, UInt32 uFlags, FILEREADCALLBACK pfnCallback, Object pUserData, LOADFILEOPTION pLoadOptions, FILEINFO pFileInfo)\r\n at Leadtools.Codecs.RasterCodecs.a(BitmapHandle A_0, b A_1)\r\n at Leadtools.Codecs.RasterCodecs.a(b A_0)\r\n at Leadtools.Codecs.RasterCodecs.Load(String fileName, Int32 bitsPerPixel, CodecsLoadByteOrder order, Int32 firstPage, Int32 lastPage)\r\n


Thanks,

Ganesh.
   Report 
  07-07-2008, 11:10
jigar is not online. Last active: 12/12/2008 5:08:42 PM jigar



Top 10 Posts
Joined on 08-22-2007
Posts 480
Re: Text file loading is taking long time...Please help!!!
Reply Quote
"Attempted to read or write protected memory" is thrown by the .NET framework.  If you are trying to read from a Stream object you can get this for any number of reasons.  Are you trying to load the TXT file into a MemoryStream and then load it with codecs.Load()?  Make sure you can read from the Stream object you are using.  Try calling the ReadByte() method and see if that throws an error.

LEADTOOLS Technical Support
   Report 
  07-07-2008, 11:33
jigar is not online. Last active: 12/12/2008 5:08:42 PM jigar



Top 10 Posts
Joined on 08-22-2007
Posts 480
Re: Text file loading is taking long time...Please help!!!
Reply Quote
Loading a page 1 at a time is slower overall, as opposed to loading 10 pages at a time.  For me it takes 60 seconds to load 10 pages, and 68 seconds if I load those 10 pages one by one.  60 seconds for 10 pages is expected since text files need to be rasterized.

LEADTOOLS Technical Support
   Report 
Post
LEAD Support Fo... » Developer » File Formats » Re: Text file loading is taking long time...Please help!!!

Powered by Community Server, by Telligent Systems