我只能扫描文档的一面,而不能扫描第二面。使用 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 Support”的回答更新了代码,但它仍在扫描页面的一侧。
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 中设置了属性
- 当它从“启用双工”询问时,我单击“是”
- 添加了用于设置属性的调试代码的屏幕截图
- 我在进纸器中有一张我想要的纸从两侧扫描