I've been going nuts trying to scan from the document feeder on my Canon imageClass MF4150. Everything worked as expected from the flatbed, no dice trying to persuade the ADF to kick in. I found some sample code but it was oriented towards devices that can detect when a document is available in the feeder. Evidently my Canon doesn't expose this and so needs to be told the source to use.
The way to do this is to set the WIA_DPS_DOCUMENT_HANDLING_SELECT property to FEEDER. You then read WIA_DPS_DOCUMENT_HANDLING_STATUS to check that it's in the right mode and initiate the scan. This did not work for toffee.
After much experimentation I discovered a solution. I had been setting device properties and then setting item properties before requesting the scan. Switching the order - item then device - made everything work.
Here's the function to scan one page:
private XImage ScanOne()
XImage ximage = null;
// find our device (scanner previously selected with commonDialog.ShowSelectDevice)
DeviceManager manager = new DeviceManager();
DeviceInfo deviceInfo = null;
foreach (DeviceInfo info in manager.DeviceInfos)
if (info.DeviceID == _deviceId)
deviceInfo = info;
if (deviceInfo != null)
Device device = deviceInfo.Connect();
CommonDialog commonDialog = new CommonDialog();
Item item = device.Items;
int dpi = 150;
// configure item
SetItemIntProperty(ref item, 6146, 2); // greyscale
SetItemIntProperty(ref item, 6147, dpi); // 150 dpi
SetItemIntProperty(ref item, 6148, dpi); // 150 dpi
SetItemIntProperty(ref item, 6151, (int)(dpi * _width)); // scan width
SetItemIntProperty(ref item, 6152, (int)(dpi * _height)); // scan height
SetItemIntProperty(ref item, 4104, 8); // bit depth
int deviceHandling = _adf ? 1 : 2; // 1 for ADF, 2 for flatbed
// configure device
SetDeviceIntProperty(ref device, 3088, deviceHandling);
int handlingStatus = GetDeviceIntProperty(ref device, 3087);
if (handlingStatus == deviceHandling)
ImageFile image = commonDialog.ShowTransfer(item, formatJpeg, true);
// save image to a temp file and then load into an XImage
string tempPath = System.IO.Path.GetTempFileName();
tempPath = System.IO.Path.ChangeExtension(tempPath, "jpg");
ximage = XImage.FromFile(tempPath);
catch (COMException ex)
ximage = null;
// paper empty
if ((uint)ex.ErrorCode != 0x80210003)
A few notes — XImage is a type from PDFSharp. I wrote this as part of a PDF scanner that I'll post next so the scanned images are saved and then loaded into an XImage for rendering to the PDF document. The magic numbers come from WiaDef.h in the Platform SDK. If the ADF is out of pages this method sets the return image to null and eats the exception. This is because the function is called repeatedly to scan in pages until the ADF is empty if _adf is true (otherwise it grabs one image from the flatbed).
If you've been banging your head against a wall trying to get WIA to work with a document feeder I hope this helps.