无法读取通过ADF扫描的第二页 [英] Cannot read second page scanned via ADF
问题描述
我有一个Brother多功能网络打印机/扫描仪/传真机(型号MFC-9140CDN).我正在尝试将以下代码用于WIA,以检索通过文档进纸器扫描的项目:
const int FEEDER = 1;
var manager=new DeviceManager();
var deviceInfo=manager.DeviceInfos.Cast<DeviceInfo>().First();
var device=deviceInfo.Connect();
device.Properties["Pages"].set_Value(1);
device.Properties["Document Handling Select"].set_Value(1);
var morePages=true;
var counter=0;
while (morePages) {
counter++;
var item=device.Items[1];
item.Properties["Bits Per Pixel"].set_Value(1);
item.Properties["Horizontal Resolution"].set_Value(300);
item.Properties["Vertical Resolution"].set_Value(300);
var img=(WIA.ImageFile)item.Transfer();
var path=String.Format(@"C:\Users\user1\Documents\test_{0}.tiff",counter);
img.SaveFile(path);
var status=(int)device.Properties["Document Handling Status"].get_Value();
morePages = (status & FEEDER) > 0;
}
首次使用Transfer
方法时,所有页面都将通过文档进纸器.第一个页面用img.SaveFile
保存到传入的路径,但是所有后续页面都不可用-device.Items.Count
为1,尝试device.Items[2]
会引发异常.
在下一次迭代中,调用Transfer
会引发一个异常-可以理解,因为供稿器中现在没有页面.
如何获取已扫描到进纸器中的后续图像?
(N.B.遍历所有设备属性,还有另一个未命名的属性,其ID为38922.我无法找到对此属性的任何引用.)
更新
我在与 WIA_DPS_SCAN_AHEAD_PAGES ,但这很有意义,因为根据文档,此属性是可选的.
我尝试使用TWAIN(强烈建议通过 NTwain 库)使用同一问题.
这是一个网络扫描仪,我正在使用WSD驱动程序.
一旦我安装了制造商的驱动程序,其行为便符合预期-在ADF中浏览一页,然后将控制权返回给程序.
(即使现在,当我使用WIA的CommonDialog.ShowSelectDevice
方法时,扫描仪也可以使用两次,一次使用Windows驱动程序,一次使用Brother驱动程序;当我选择WSD驱动程序时,仍然可以看到问题.)>
I have a Brother mutlifunction networked printer/scanner/fax (model MFC-9140CDN). I am trying to use the following code with WIA, to retrieve items scanned in with the document feeder:
const int FEEDER = 1;
var manager=new DeviceManager();
var deviceInfo=manager.DeviceInfos.Cast<DeviceInfo>().First();
var device=deviceInfo.Connect();
device.Properties["Pages"].set_Value(1);
device.Properties["Document Handling Select"].set_Value(1);
var morePages=true;
var counter=0;
while (morePages) {
counter++;
var item=device.Items[1];
item.Properties["Bits Per Pixel"].set_Value(1);
item.Properties["Horizontal Resolution"].set_Value(300);
item.Properties["Vertical Resolution"].set_Value(300);
var img=(WIA.ImageFile)item.Transfer();
var path=String.Format(@"C:\Users\user1\Documents\test_{0}.tiff",counter);
img.SaveFile(path);
var status=(int)device.Properties["Document Handling Status"].get_Value();
morePages = (status & FEEDER) > 0;
}
When the Transfer
method is reached for the first time, all the pages go through the document feeder. The first page gets saved with img.SaveFile
to the passed-in path, but all the subsequent pages are not available - device.Items.Count
is 1, and trying device.Items[2]
raises an exception.
In the next iteration, calling Transfer
raises an exception -- understandably, because there are now no pages in the feeder.
How can I get the subsequent images that have been scanned into the feeder?
(N.B. Iterating through all the device properties, there is an additional unnamed property with the id of 38922. I haven't been able to find any reference to this property.)
Update
I couldn't find a property on the device corresponding to WIA_IPS_SCAN_AHEAD or WIA_DPS_SCAN_AHEAD_PAGES, but that makes sense because this property is optional according to the documentation.
I tried using TWAIN (via the NTwain library, which I highly recommend) with the same problem.
This is a networked scanner, and I was using the WSD driver.
Once I installed the manufacturer's driver, the behavior is as expected -- one page goes through the ADF, after which control is returned to the program.
(Even now, when I use WIA's CommonDialog.ShowSelectDevice
method, the scanner is available twice, once using the Windows driver and once using the Brother driver; when I choose the WSD driver, I still see the issue.)
这篇关于无法读取通过ADF扫描的第二页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!