Closed seevali closed 2 years ago
The readme has a code sample for duplex. Have you tried that?
Yes. It throws an error when setting below;
item.SetProperty(WiaPropertyId.IPS_DOCUMENT_HANDLING_SELECT, WiaPropertyValue.DUPLEX | WiaPropertyValue.FRONT_FIRST);
Error: Could not set property 3088 (Document Handling Select) value to "12
But I found this SOF answer https://stackoverflow.com/a/30938732/1550721.
And calling the item.StartTransfer()
twice I was able to get images of both sides.
Sample code:
device.SetProperty(WiaPropertyId.IPS_DOCUMENT_HANDLING_SELECT, WiaPropertyValue.FEEDER | WiaPropertyValue.DUPLEX);
device.SetProperty(WiaPropertyId.IPS_PAGES, 1);
item.SetProperty(WiaPropertyId.IPS_DOCUMENT_HANDLING_SELECT, WiaPropertyValue.DUPLEX);
try
{
while (true)
{
using var transfer1 = item.StartTransfer();
transfer1.PageScanned += (sender, args) =>
{
using (args.Stream)
{
var bitmap = new Bitmap(args.Stream);
// Do something with the image
}
};
// Do the actual scan
transfer1.Download();
using var transfer2 = item.StartTransfer();
transfer2.PageScanned += (sender, args) =>
{
using (args.Stream)
{
var bitmap = new Bitmap(args.Stream);
// Do something with the image
}
};
// Do the actual scan
transfer2.Download();
}
}
catch (WiaException ex) when (ex.ErrorCode == WiaErrorCodes.PAPER_EMPTY)
{
}
I've removed FRONT_FIRST from the readme as it may not be well supported. Also I've added a line to set IPS_PAGES to ALL_PAGES (0) which is at least supposed to mean that you don't need to call StartTransfer/Download multiple times (though I haven't tested this with a duplex scanner).
With the below settings, the NAPS2 (desktop) application automatically scans all the documents in Duplex mode (see Paper Source).
But in this library I can't set Duplex (refer bellow code snipet)
I can scan all the documents by calling
transfer.Download()
until all the documents are scanned.Please help to implement this.
PS: OR Is it possible to use the
NAPS2.Core.dll
(found in the installation directory of NAPS2.exe) and achieve my requirment?