Contact us


All times are UTC - 8 hours



Post new topic Reply to topic  [ 3 posts ] 
Author Message
Offline Profile  


Joined: Thu Mar 12, 2015 12:59 am
Posts: 1
I want to use dynamic twain to scan multi documents from feeder as the following :putting pages for all documents in feeder , start scanning ,scan 1 page "1 as example" then stop transferring from feeder ,save the scanned page as one document and then continue feeding until the paper is out.
this is my code :

try
{
dynamicDotNetTwain.IfDisableSourceAfterAcquire = true;
dynamicDotNetTwain.OpenSource();
dynamicDotNetTwain.IfShowUI = false;
if (isScanFromFeeder == true)
{
dynamicDotNetTwain.IfFeederEnabled = true;
dynamicDotNetTwain.IfAutoFeed = true;
dynamicDotNetTwain.XferCount = 1;
}
else
{
dynamicDotNetTwain.IfFeederEnabled = false;
dynamicDotNetTwain.IfAutoFeed = false;
}

dynamicDotNetTwain.IfDuplexEnabled = false;
dynamicDotNetTwain.PixelType = Dynamsoft.DotNet.TWAIN.Enums.TWICapPixelType.TWPT_RGB;//colored scanning
dynamicDotNetTwain.BitDepth = 24;
dynamicDotNetTwain.TransferMode = 0;
dynamicDotNetTwain.Resolution = 100;
if (!dynamicDotNetTwain.AcquireImage())
MessageBox.Show(dynamicDotNetTwain.ErrorString, "Scan error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception excp)
{
MessageBox.Show("An exception occurs: " + excp.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

can you help , please !


User avatar
Offline Profile  


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1691
Hi Hiba,

If you want to save images while you are scanning images, you can use the event dynamicDotNetTwain_OnPostTransfer().

If you want to save multiple images as one document, you can try the method SaveAsMultiPagePDF or SaveAsMultiPageTIFF in the link below:

http://www.dynamsoft.com/help/TWAIN/.Net-TWAIN-Scanner/html/AllMembers_T_Dynamsoft_DotNet_TWAIN_DynamicDotNetTwain.htm

Kindly let me know if it works for you. :)

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


Offline Profile  


Joined: Thu Dec 17, 2015 10:44 am
Posts: 1
This imply each scanned page can be saved in the dynamicDotNetTwain_OnPostTransfer() event.
The problem is that scanners with feeders scan all the pages in the feeder and give you one event call to dynamicDotNetTwain_OnPostTransfer();

If you are in TWICapSetupXFer.TWSX_NATIVE mode you might as well wait for dynamicDotNetTwain.EnableSource(); to return and then one by one traverse the Images Buffer using dynamicDotNetTwain.GetImage(index) and write each to file. Then when finished call dynamicDotNetTwain.RemoveAllImages(); The problem with this for x86 apps is that it is memory expensive. Scan 20 pages with duplex on at 300 or 600 DPI you will cause an out of memory error.

if you are using TWICapSetupXFer.TWSX_FILE only the last page scanned will be saved. All other scanned pages are lost. Where are they?

I know TWAIN can feed one page at a time and hand you the result. At this point you can save it, dispose of the source image and ask for the next. The issue I am having is that I do not know how to get this library to do that.

I have solved the problem using Native Mode.
This will step through each scanned image bringing one into memory at a time.
No more huge memory spike.
Code:
{
  dynamicDotNetTwain = new Dynamsoft.DotNet.TWAIN.DynamicDotNetTwain();
  dynamicDotNetTwain.LicenseKeys = "your license key"
  dynamicDotNetTwain.ScanInNewProcess = true;
  dynamicDotNetTwain.OnPostTransfer += new   Dynamsoft.DotNet.TWAIN.Delegate.OnPostTransferHandler(dynamicDotNetTwain_OnPostTransfer);

  dynamicDotNetTwain.OpenSource();

  dynamicDotNetTwain.IfFeederEnabled = true;
  dynamicDotNetTwain.XferCount = -1;
  dynamicDotNetTwain.IfAutoFeed = true; //auto feed
  dynamicDotNetTwain.MaxImagesInBuffer = 1; // This is KEY
  dynamicDotNetTwain.IfDuplexEnabled = true;
  dynamicDotNetTwain.IfShowUI = false;
  dynamicDotNetTwain.IfShowIndicator = false;
  dynamicDotNetTwain.IfDisableSourceAfterAcquire = true;
  dynamicDotNetTwain.EnableSource();
}

void dynamicDotNetTwain_OnPostTransfer()
{
  dynamicDotNetTwain.JPEGQuality = 40;
  string strFileName = FilenameHandler.GetTempFileName();
  dynamicDotNetTwain.SaveAsJPEG(strFileName, 0);
  dynamicDotNetTwain.RemoveAllImages(); // This is KEY
}



Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ]  Moderators: Michael, Vincy


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Copyright © 2016 Dynamsoft | All Rights Reserved
dynamic designed by Dynamsoft team