1

在我的应用程序中,我正在使用 TwainDotNet 库,并且正在从平板扫描特定区域。

public Prasymas scanForm(Prasymas prasymas, bool isItFirstScan)
    {

        Enabled = false;

        _settings = new ScanSettings();
        _settings.UseDocumentFeeder = false;
        _settings.ShowTwainUI = false;
        _settings.ShowProgressIndicatorUI = true;
        _settings.UseDuplex = false;
        _settings.Resolution =
            false
            ? ResolutionSettings.Fax : ResolutionSettings.ColourPhotocopier;
        _settings.Page = PageSettings.Default;

        if (!isItFirstScan) 
        {
            _prasymas = prasymas;
            AreaSettings = new AreaSettings(Units.Centimeters, 0.0f, 0.0f, (float)(_prasymas.maxScanAukstis), 0.0f);                
        }
        else
        {
            _settings.Area = !false ? null : AreaSettings;
        }
        _settings.ShouldTransferAllPages = true;


        _settings.Rotation = new RotationSettings()
        {
            AutomaticRotate = false,
            AutomaticBorderDetection = false
        };

        try
        {
            _twain.SelectSource();
            _twain.StartScanning(_settings);
        }
        catch (TwainException ex)
        {
            if (ex.Message == "Error opening data source")
            {
                _twain.SelectSource();
                scanForm(_prasymas, isItFirstScan);
                Enabled = true;
            }
            else
                throw ex;

        }
        catch (Exception exc)
        {
            if (exc.Message == "Pasiuto skeneris")
            {
                scanForm(_prasymas, true);                    
            }
            else
                throw exc;

        }

        Enabled = true;
        return prasymas;
    }

但结果当扫描开始并且扫描源是 Twain 驱动程序时,它会扫描整页,但如果我选择 WIA 驱动程序,我会得到专门选择的区域。主要思想是应用程序在第一次扫描整页时启动,下次它只扫描页面的特定高度。

4

1 回答 1

0

阅读文档后,我发现只需要注释掉旋转部分,一切就开始工作了。我可以扫描选定的区域。

于 2015-02-18T13:09:33.580 回答