Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, February 16, 2012 4:02:17 AM(UTC)

NikkiOs  
NikkiOs

Groups: Registered
Posts: 5


Hi

I'm referring this c# example:
http://www.leadtools.com/help/leadtools/v175/dh/ft/leadtools.forms.documentwriters~leadtools.forms.documentwriters.ltddocumentoptions.html

I'm trying to scan pages and append them to ltd-file. The examples problem is that i have no idea about how to generate the needed emf-files (or needed at all at my case?). Another problem is that docWriter.convert throws me "file not found" -error when I do it like this.

Is the problem within the missing emf or something else?

---
      DocumentPage page = DocumentPage.Empty;
      //page.EmfHandle = emfHandle; //not using this now
      //RasterImage from twainAcquirePageEvent(object o,TwainAcquirePageEventArgs args)
      page.Image = args.Image;
      docWriter.AddPage(page);
---
      PdfDocumentOptions pdfOptions = docWriter.GetOptions(DocumentFormat.Pdf) as PdfDocumentOptions;
      pdfOptions.DocumentType = PdfDocumentType.Pdf;
      docWriter.SetOptions(DocumentFormat.Pdf, pdfOptions);
      docWriter.Convert("c:/test.ltd", "c:/test.pdf", DocumentFormat.Pdf);
---




 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Thursday, February 16, 2012 6:29:52 AM(UTC)

Daoud  
Daoud

Groups: Registered
Posts: 256


There's something missing in your code, and what it is depends on what you are trying to do:
1) If you're trying to save text-based (searchable) PDF, you cannot simply scan images and append them to a document. You must first convert the scanned image to text using Optical Character Recognition (OCR). After OCRing the pages, you can create multi-page text-based files such as PDF.

2) If you're trying to save image-based (Raster bitmaps) PDF, you do not need the document writer classes. You can simply use RasterCodecs.Save method to write the raster PDF just like you save any image format.

 
#3 Posted : Friday, February 17, 2012 12:33:37 AM(UTC)

NikkiOs  
NikkiOs

Groups: Registered
Posts: 5


Sorry, the first question came out wrong, I tried to reply one post and it was locked so this question was out of context now.

The problem I'm having is that one of our clients is scanning quite large bunch of paper at one try, and then He gets "not enough memory" -error.

I also tried this kind of HC-scanning with CS_MainDemo_x86 (v16.5) and got the same error.
(printscreen attachment) (scanner read 30+ pages with colors, duplex and 300dpi to make sure it uses much memory)

On our solution the AcquirePageEvent is appending a tif-file to harddisk but it seems it isn't enough to prevent this situation, what could I do?

---
private void twainAcquirePageEvent(object sender, TwainAcquirePageEventArgs evt)
---
_codecs.Save(evt.Image, GlobalsWrapper.ScanFileName+GlobalsWrapper.SAVEINFO_FILEFORMAT_TIF, getSaveSubFormat(GlobalsWrapper.SAVEINFO_FILEFORMAT_TIF), 0, 1, 1, 1, CodecsSavePageMode.Append);
---
 
#4 Posted : Sunday, February 19, 2012 4:28:38 AM(UTC)

Daoud  
Daoud

Groups: Registered
Posts: 256


Hello,
If you want to only append scanned pages to TIFF file and do not need to keep them in memory afterwards, the process should not consume memory to the point of failing.

If possible, I want to test this here so please send me full details. For example, what do you mean by "HC-scanning" and how exactly did you try it with our demo? If there are steps I need to take to see the problem, please explain them in full detail.

If the problem only happens in your code, please create a small test project (not your full application) that does not any external classes (such as GlobalsWrapper mentioned in your code above) and send it to us in a ZIP or RAR file. You can either post it here or email it to support@leadtools.com

Please note that your post did not include any attachments. If you are attaching a file to forums, please make sure to do the following:
1) Put it in ZIP or RAR file.
2) Do NOT use the "Preview" option when posting a thread.

 
#5 Posted : Monday, February 20, 2012 12:11:20 AM(UTC)

NikkiOs  
NikkiOs

Groups: Registered
Posts: 5


Ok, this is how I did it with your demo:

1. I have virtualized win7 x64 as my platform, installed memory shows: 1,52 GB (for virtualized machine this is quite enough for developing).

2. Open project (CSMainDemo_x86, from leadtools version 16.5), my development tool is visual studio 2010 so the project had to be converted at start.

3. Run program and select: file - twain aquire: select scanning settings as: 24bit color, 300dpi, scanning side: duplex, scanning option: scan ahead.

4. I had about 30 pages in scanner (Canon DR-3010C) when i pressed "Scan".

5. see attachment, if it came through at this time :)

6. It seems the memory error disappears if i change to another aquire function:
---
private void _menuItemFileTwainAcquire_Click(object sender, EventArgs e)
{
#if LTV16_CONFIG || !FOR_WIN64
         _inTwainAcquire = true;
         _acquirePageCount = 1;

         try
         {
            if(_twainSession != null)
            {
               //DialogResult res = _twainSession.Acquire(TwainUserInterfaceFlags.Modal | TwainUserInterfaceFlags.Show);

              _twainSession.AcquireFast("c:/temp/aquire.tif",
                TwainFastUserInterfaceFlags.Show,
                TwainTransferMode.Buffer,
                RasterImageFormat.Tif,
                1,true,0, true);
            }
         }
---


File Attachment(s):
scan images - not enough memory.zip (260kb) downloaded 31 time(s).
 
#6 Posted : Monday, February 20, 2012 7:18:02 AM(UTC)

Daoud  
Daoud

Groups: Registered
Posts: 256


If you use this demo without any change, Twain scanning will add all pages to memory in the _twainSession_AcquirePage event handler. This means it is normal for this demo to require significant amount of memory when performing mutli-page Twain scanning.

If you only want to save to disk, do not store the pages to memory in the TwainSession.AcquirePage event handler. Instead, take the e.Image that is passed by the event and use it with RasterCodecs.Save() method to store it to disk.

 
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.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.089 seconds.