需要使用Leadtools WIA扫描文档的两面

时间:2017-11-08 09:37:16

标签: c# asp.net image-scaling leadtools-sdk

我只能扫描文档的一面而不能扫描第二面。使用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);

更新代码:,我根据" LEADTOOLS支持"的回答更新了代码。但它仍在扫描页面的一面。

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);
     }
  }

注意:
- 我调试了代码,并在wiaSession_EnumItemsEvent中设置了属性 - 当它从&#34;启用双工&#34;时,我点击是
- 添加了用于设置属性的调试代码的屏幕截图 - 我在进纸器中有一张纸,我想从两面扫描

enter image description here

功能选项: enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

假设进纸器中有1张纸,扫描双面的代码需要指定2页,每边一页。这可以使用WiaProperties.MaximumNumberOfPages属性完成。然后使用WiaProperties.ScanningMode属性启用双面扫描。代码如下所示:

session_id