In my application I am using TwainDotNet library and I am scanning a specific area from flatbed.
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;
}
but in result when scanning starts and a scan source is Twain driver it scans full page, but if I choose WIA driver I get specifically selected area. Main Idea is then App starts for the first time it scans full page, next time it scans only specific height of the page.
After reading documentation I found out that just needed to comment out rotation part and everything started to work. I can scan selected area.