I am trying to scan a few pages from the feeder, although the scanner automatically scans all the pages when I call ShowTransfer function (without using a loop), I am getting back only the first page.
what am I doing wrong?
here's my code:
WIA.Item item = device.Items[1] as WIA.Item;
if (pages > 1)
{
// Set to feeder
SetWIAProperty(device.Properties, 44, 1);
}
SetWIAProperty(device.Properties, WIA_DEVICE_PROPERTY_PAGES_ID, 1);
AdjustScannerSettings(item, 150, 0, 0, 1250, 1700, 0, 0, 1);
try
{
// scan image
WIA.ICommonDialog wiaCommonDialog = new WIA.CommonDialog();
WIA.ImageFile image = (WIA.ImageFile)wiaCommonDialog.ShowTransfer(item, wiaFormatBMP, false);
// save to temp file
string fileName = Path.GetTempFileName();
File.Delete(fileName);
image.SaveFile(fileName);
image = null;
// add file to output list
images.Add(Image.FromFile(fileName));
}
catch (Exception exc)
{
throw exc;
}
You can scan multiple pages of a document, magazine, or newspaper and save them as one PDF file on your computer. Epson Scan displays an editing page so you can view the pages as you scan them and reorder, rotate, or delete them as necessary. Place your original document or photo on the scanner.
I think this link is doing what you want to do
http://forums.codeguru.com/showthread.php?439027-Windows-Image-Acquisition-(WIA)-Code
Basically, you need to check after saving off each page to see if there are more pages and keep looping
hasMorePages = false; //assume there are no more pages
if (documentHandlingSelect != null)
//may not exist on flatbed scanner but required for feeder
{
//check for document feeder
if ((Convert.ToUInt32(documentHandlingSelect.get_Value()) & WIA_DPS_DOCUMENT_HANDLING_SELECT.FEEDER) != 0)
{
hasMorePages = ((Convert.ToUInt32(documentHandlingStatus.get_Value()) & WIA_DPS_DOCUMENT_HANDLING_STATUS.FEED_READY) != 0);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With