C#: Online Guide
How To: Twain SDK
Install, Deploy and Distribute
Home ›› XImage.Twain ›› C# Twain: Install, Deploy and Distribution

C# TWAIN - Install, Deploy and Distribute XImage.Twain Control

Online C# Guide for XImage.Twain Installation, Deployment and Distribution

There are three parts on this page, including system requirements for using XImage.Twain SDK, C#.NET TWAIN Scanning Basic Classes and how to install XImage.Twain into visual studio C# .NET Applications.

Note: Since our .NET Twain Add-on is a dll that is built on official Twain driver, C#.NET programmers should install the official TWAINDSM.dll (provided in our dlls collection) manually before using RasterEdge.Imaging.Twain. Simply put TWAINDSM.DLL in x86 folder under the Windows System directory (normally C:\Windows\System32). On a 64bit system, please make sure TWAINDSM.DLL in x64 folder ends up in the WOW64 System directory (normally C:\Windows\SysWOW64).

Related .net document control helps:
asp.net powerpoint document viewer: ASP.NET PowerPoint Document Viewer Control: view pptx files online in C# using ASP.NET
asp.net pdf file permission: ASP.NET PDF File Permission Control: apply, remove PDF file permission settings in C#
asp.net convert pdf: ASP.NET Convert PDF Control: Convert, export PDF to Word, HTML, Tiff files in C# ASP.NET
asp.net dnn document viewer: DNN Document Viewer Control: view, annotate, redact, convert documents in dotnetnuke ASP.NET
document redact asp.net: Redact document ASP.NET: add, delete, apply redaction on PDF files in web browser using C#.net
asp.net open pdf password: ASP.NET PDF Password Edit Control: online add, remove, update PDF file open password using C#
asp.net redact pdf: ASP.NET Redact PDF Document Control: redact, remove PDF text, images in web browser using C# ASP.NET

System Requirements

Windows XP SP3 or later

Microsoft .NET Framework 2.0 or later

C#.NET TWAIN Scanning Basic Classes

To help you have a better and quicker grasp of our .NET TWAIN Scanning Add-on, we here expressly illustrate its two basic classes, which can be used in C#.NET program.

C# TWAIN Class: Acquisition

Acquisition object is the primary class in RETwain. C#.NET programmers can drop this .NET component onto a Form after adding it to VS Toolbox, or instantiate it directly. This is the only class you need to add standard image acquisition capabilities to C#.NET TWAIN image scanning application. For greater control over TWAIN image acquisition process, this class contains a collection of Device objects that control numerous properties used for image acquisition.

C# TWAIN Class: TWAINDevice

TWAINDevice object provides full access to a TWAIN compatible source on the system. C#.NET users can use it to open a connection to a TWAIN device, get and set properties, and then acquire one or more images. However, this class represents a system device resource and users cannot create an instance of it. Instead, in C#.NET TWAIN scanning application, users can obtain an instance to a Device object by calling GetAvailbleDevices, or from the Devices collection in the Acquisition object.

Install XImage.Twain in C# Project

Add necessary references to your C#.NET project. Right-click the project and select "Add Reference..." to locate and add the following DLLs as project references;











Use corresponding namespaces;





Add the following C# demo code to your project (set twain device ability).

public void QueryDeviceCapabilities(Device device)
   // Open a connection to the device.
   device.TransferMode = TwainTransferMode.TWSX_NATIVE;

   // See if the device supports file transfer.
   TwainTransferMode[] methods =
   foreach (TwainTransferMode method in methods)
      if (method == TwainTransferMode.TWSX_FILE2)
            // Use TWSX_FILE2 when possible.
            device.TwainTransferMode = method;

            if (method == TwainTransferMethod.TWSX_FILE)
            device.TransferMethod = method;

   // If it's not supported tell stop.
   if (device.TransferMode == TwainTransferMode.TWSX_NATIVE)
      // Close the connection.
      Console.WriteLine("File Transfer not supported");

   // Find out which file types the device can save to.
   TwainImageFormat[] formats = device.GetSupportedImageFormats();
   // We want to save the image as a TIFF.
   foreach (TwainImageFormat format in formats)
      if (format == TwainImageFormat.Tiff)
            // TIFF is supported, so set the FileFormat.
            device.FileFormat = format;
            // Now lets try to use Group4 or Group3 compression.
            // We could use GetSupportedCompressionModes, but we
            // will simply try setting the Compression property instead.
            device.Compression = TwainCompressionMode.Group4;
            if (device.Compression != TwainCompressionMode.Group4)
            device.Compression = TwainCompressionMode.Group3;

   // Start the acquire process, using the device's interface.

   // don't forget to close the connection after done