Accusoft.TwainPro9.Net
Initiate a Scanning Session

Prior to initiating a scanning session, the following should be done:

Once a Scanning session has been initiated (StartSession), capabilities, caption, and layout can be checked, but can no longer be modified.

Initiate Scanning Using the Data Source UI

To enable the application end user to initiate image acquisition, ensure that the TwainDevice.ShowUserInterface property is set to True. Then call the StartSession method.

The Data Source User Interface then displays the current or default Data Source User Interface for image acquisition.  

C# Example
Copy Code
// This code demonstrates how to select the Data Source UI and then acquire an image from the Data Source
private void cmdScan_Click(object sender, EventArgs e)
{
 twainDevice.SelectSource();
 twainDevice.ShowUserInterface = true
 twainDevice.StartSession();
}
 
// After the image is acquired you can place it into the windows clipboard then into other applications
// or controls.
public void twainDevice_Scanned(object sender, Accusoft.TwainProSdk.ScannedEventArgs e)
{
 try
 {
  e.ScannedImage.CutToClipboard();
 }
 catch (Accusoft.TwainProSdk.TwainProException ex)
 {
  ErrorLabel.Text = ex.Message;
 }
}

Initiate Scanning Without Using the Data Source UI

The TwainDevice.ShowUserInterface property is used to set the Data Source User Interface visibility to True or False. To hide the Data Source's User Interface, you must use the TwainPRO session methods. The ShowUserInterface property has to be set before calling the StartSession method.

When acquiring an image without the Data Source User Interface, you must take into account that the default image size and resolution capabilities may create a very large image and your system may not have enough memory for the image transfer. Check the image height, width, and resolution settings using the ImageLayout property and ICAP_XRESOLUTION capability respectively. If these values are outside of your parameters then you can change them with the ImageLayout property and SetCapability method.

 

See Also

 

 


©2014. Accusoft Corporation. All Rights Reserved.

Send Feedback