1

I can only scan one side of the document but not the second side. What are settings I need to achieve both side of scan using Wia Leadtools.

WiaAcquireFlags flags = WiaAcquireFlags.None;
bool showProgress = true;
_progressDlg = new ProgressForm("Transferring", "", 100);
_wiaAcquiring = true;                   

if (_showUserInterface)
{
    flags = WiaAcquireFlags.UseCommonUI | WiaAcquireFlags.ShowUserInterface;
}
else
{
    if (SelectAcquireSource() != System.Windows.Forms.DialogResult.OK)
    {
        _wiaAcquiring = false;
        return;
    }
}

if (_showUserInterface && _wiaVersion == WiaVersion.Version2)
    showProgress = false;

if (showProgress)
    _progressDlg.Show();

_wiaSession.AcquireOptions = _wiaAcquireOptions;
_transferMode = (_wiaProperties.DataTransfer.TransferMode == WiaTransferMode.None) ? WiaTransferMode.Memory : _wiaProperties.DataTransfer.TransferMode;


//#if !LEADTOOLS_V19_OR_LATER
System.Windows.Forms.DialogResult dialogResult = _wiaSession.Acquire(mainWindowHandle, _sourceItem, flags);

Updated Code:, I have updated code according to answer of "LEADTOOLS Support" but it is still scanning 1 side of page.

public void Scan()
{
    ...
    ...
    ...
    object rootItem = _wiaSession.GetRootItem(null);
    if (rootItem != null)
    {
     wiaSession.EnumItemsEvent += new EventHandler<WiaEnumItemsEventArgs>       (wiaSession_EnumItemsEvent);    
     wiaSession.EnumChildItems(rootItem);
     wiaSession.EnumItemsEvent -= new EventHandler<WiaEnumItemsEventArgs>(wiaSession_EnumItemsEvent);

     wiaSession.AcquireOptions = _wiaAcquireOptions;
     transferMode = (_wiaProperties.DataTransfer.TransferMode == WiaTransferMode.None) ? WiaTransferMode.Memory : _wiaProperties.DataTransfer.TransferMode;

    //#if !LEADTOOLS_V19_OR_LATER
      System.Windows.Forms.DialogResult dialogResult = _wiaSession.Acquire(mainWindowHandle, _sourceItem, flags);

    ...
    ...
    ...
}
public void wiaSession_EnumItemsEvent(object sender, WiaEnumItemsEventArgs e)
{
   if (e.Item != null)
   {               

    WiaProperties wiaProperties = _wiaSession.GetProperties(e.Item);
        if (System.Windows.Forms.MessageBox.Show("Enable duplex?", "WIA test", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
        {
           wiaProperties.ScanningMode = WiaScanningModeFlags.Feeder | WiaScanningModeFlags.Duplex;
           wiaProperties.MaximumNumberOfPages = 2;
        }
        else
        {
          wiaProperties.ScanningMode = WiaScanningModeFlags.Feeder | WiaScanningModeFlags.FrontOnly;
          wiaProperties.MaximumNumberOfPages = 1;
        }
          wiaSession.SetProperties(e.Item, wiaProperties);
     }
  }

Note:
- I have debugged the code and it sets properties in wiaSession_EnumItemsEvent
- When it asks from "Enable duplex", I click YES
- Added screenshot of debugging code for setting properties
- I have 1 sheet of paper in the feeder that I want to scan from both sides

enter image description here

Capabilities Options: enter image description here

enter image description here

Cute Sparrow
  • 37
  • 1
  • 9

1 Answers1

0

Assuming you have 1 sheet of paper in the feeder, the code to scan both sides needs to specify 2 pages, one for each side. This can be done using the WiaProperties.MaximumNumberOfPages property. Enabling 2-sided scanning is then done using the WiaProperties.ScanningMode property. The code looks like this:

WiaProperties wiaProps = _wiaSession.GetProperties(wiaItem);
if (MessageBox.Show("Enable duplex?", "WIA test", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
{
   wiaProps.ScanningMode = WiaScanningModeFlags.Feeder | WiaScanningModeFlags.Duplex;
   wiaProps.MaximumNumberOfPages = 2;
}
else
{
   wiaProps.ScanningMode = WiaScanningModeFlags.Feeder | WiaScanningModeFlags.FrontOnly;
   wiaProps.MaximumNumberOfPages = 1;
}
_wiaSession.SetProperties(wiaItem, wiaProps);
LEADTOOLS Support
  • 2,755
  • 1
  • 12
  • 12
  • I have updated code according to your answer but it is still scanning 1 side of document. Can you please look into code what I am missing. – Cute Sparrow Nov 13 '17 at 05:17
  • Are you using WIA version 1.0 or 2.0? If you run our WIA demo and choose "Show supported capabilities..." from the Capabilities menu, do you get a "Select Item" dialog with a tree view inside it? What are the listed capabilities for each item in the tree? – LEADTOOLS Support Nov 14 '17 at 18:57
  • _wiaSession.Startup(WiaVersion.Version2); – Cute Sparrow Nov 15 '17 at 09:49
  • I have added two more images for "Capabilities Options" – Cute Sparrow Nov 15 '17 at 09:53
  • Upon testing with a feeder-only scanner, we ran into a problem similar to yours. It turns out our scanner's driver needs a certain group of properties to be set in a specific order to enable duplex scanning. One way to determine the needed properties and their order is by using an approach that's guaranteed to enable duplex on that scanner, such as displaying the manufacturer's dialog box, then checking all the property values. If you need help with this, please email support@leadtools.com since this could take several back-and-forth emails before it gets pinned down precisely. – LEADTOOLS Support Nov 17 '17 at 01:01