WIA 2.0 Duplex property
I am developing an aplication with C# to use the WIA 2.0 library. At the moment I could use most of the features, such as ADF (auto document feeder), filters and more.
Now, I need to use the duplexer of my scanner (fujitsu).
I'm trying to set the WIA_DPS_DOCUMENT_HANDLING_SELECT scanner property to the DUPLEX value. See the code below:
try
{
bool hasMorePages = false;
//determine if there are any more pages waiting
Property documentHandlingSelect = null;
Property documentHandlingStatus = null;
foreach (Property prop in WiaDev.Properties)
{
if (prop开发者_如何学C.PropertyID == WIA_PROPERTIES.WIA_DPS_DOCUMENT_HANDLING_SELECT)
documentHandlingSelect = prop;
if (prop.PropertyID == WIA_PROPERTIES.WIA_DPS_DOCUMENT_HANDLING_STATUS)
documentHandlingStatus = prop;
}
object obj = new object();
obj = (WIA_DPS_DOCUMENT_HANDLING_SELECT.DUPLEX);
documentHandlingSelect.set_Value(ref obj);
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 (hasMorePages)
{
// set the property to use FEEDER and DUPLEX (this result in the value of 5 in the property)
object obj = new object();
obj = (WIA_DPS_DOCUMENT_HANDLING_SELECT.FEEDER | WIA_DPS_DOCUMENT_HANDLING_SELECT.DUPLEX);
documentHandlingSelect.set_Value(ref obj);
}
}
}
return hasMorePages;
This code compiles ok, but I am no able to get two images when I execute this line. It retrieves only the front:
imgFile = (ImageFile)wiaCommonDialog.ShowTransfer(item, format.Guid.ToString("B")/* wiaFormatJPEG*/, false);
I read into many topics, and also in the documentation, that it is possible to get Children objects form the Item on the scanner, but there is only one Item in this collection.
Please, someone help me!
Thanks
I've read that one you transfer the first image the second image is available using the same reference so you just call the first line of code twice. It seems a bit strange but works with one of my duplex scanners.
e.g.
imgFile = (ImageFile)wiaCommonDialog.ShowTransfer(item, format.Guid.ToString("B")/* wiaFormatJPEG*/, false);
imgFile2 = (ImageFile)wiaCommonDialog.ShowTransfer(item, format.Guid.ToString("B")/* wiaFormatJPEG*/, false);
This may work for you. I'm also having trouble with duplex scanning but I managed to get this to work with one of my scanners.
精彩评论