C#: Online Guide
How To: Twain SDK
Open and Close Connection to Twain Devices
Open and Close Connection to Twain Devices
  |  
Home ›› XImage.Twain ›› C# Twain: Open and Close Connection to Twain Devices

C# TWAIN - Open & Close Connection to Twain Device


How to Open and Close Connection to Twain Devices in C#.NET Applications




Open & Close Connection to Twain Devices C# Overview



Developers can use our C#.NET TWAIN Scanning Add-On to open and close connection to Twain devices in an easy way. For developers who want to query or set properties of Twain device in C#, a connection to the Twain device must be invoked. When the connection to Twain devices is invoked in C# TWAIN image scanning program, it is available to retrieve some default values of the device. After all desired properties or all of the images have been acquired, the Twain device connection should be closed manually. c# excel to pdf, vb.net pdf reader control, c# pdf reader table, c# pdfbox extract text, add password to pdf c#, tiff to bitmap c#. When the connection is closed, all of the device properties will be reset to their default values.


Related .net document control helps:
asp.net mvc image viewer: ASP.NET Image Viewer Control(MVC & WebForms): view, annotate, redact, convert image files in html, JQuery
asp.net dicom library: ASP.NET Dicom Document Viewer Control: view, annotate dicom imaging files online in ASP.NET
asp.net document viewer example: EdgeDoc:ASP.NET Document Viewer C# Control: Open, view, annotate, redact, convert documents online in C#, VB.NET, AS...
asp.net edit pdf image control: ASP.NET PDF Image Edit Control: online insert, edit PDF images in C#
asp.net edit pdf page control: ASP.NET PDF Pages Edit Control: add, remove, sort, replace PDF pages online using C#
asp.net view excel in browser: ASP.NET Excel Viewer in C# Control (MVC & WebForms): view Office Excel document in web browser.
asp.net sharepoint document viewer control: ASP.NET SharePoint Document Viewer: view, annotate, redact documents in SharePoint


Our C#.NET TWAIN Add-On not only supports developers to open and close connection to Twain devices, but also enables you to query and customize Twain device properties, set image size and location for C# Twain scanning or realize featured TWAIN scanning in C#.NET applications. Moreover, RETwain can be used to add a web deployed scanning control to your client application. Using our C# web document image viewer and annotation component, this feature can be realized. If you are a VB.NET developer, please see: How to Open and Close TWAIN Device Connection in VB.NET.


If you want to use our C#.NET TWAIN Add-On to open and close connection to Twain devices in C#.NET applications, you may need to make some preparations. For example, you need to install .NET Framework 2.0 or later versions at first. Then, check whether Visual Studio 2005 or any later version is installed to create the C#.NET project. convert pdf to html programmatically c#, itextsharp insert image in pdf vb.net, c# itextsharp add image to pdf, convert text to pdf c#, c# pdf extract pages, c# pdf editor, convert pdf to bitmap vb.net. Finally, please make sure if TWAIN is installed in your system. If TWAIN is installed, at any rate one Twain device should be available too.


This C#.NET guide page is divided into five main sections. On this guide page, you will find information on brief introduction of our C#.NET TWAIN Image Scanning Add-On, DLLs and Licenses for opening and closing connection to Twain devices with this Add-On, APIs and demo code needed to open and close connection to Twain devices in C#.NET, as well as more device control related guides for C#.NET to help you understand Twain device control well. asp.net open excel file, mvc 5 display pdf in view, asp.net core pdf preview, asp.net core image viewer, how to show pdf file in asp.net c#, how to add header and footer in pdf using itextsharp in asp.net, asp.net pdf editor.




DLLs & Licenses: Open & Close Connection to Twain Devices



To achieve opening and closing connection to Twain devices with our C#.NET TWAIN Add-On, the following dlls should be added to your Visual C#.NET project references.



RasterEdge.Imaging.Basic.dll


RasterEdge.XImage.Raster.dll


RasterEdge.XImage.Raster.Core.dll


RasterEdge.Imaging.Basic.Codec.dll


RasterEdge.XDoc.PDF.dll


RasterEdge.Imaging.Drawing.dll


RasterEdge.Imaging.Font.dll


RasterEdge.Imaging.Processing.dll


RasterEdge.Imaging.WinformsControl.Twain.dll


To use our C#.NET TWAIN Imaging Library under commercial conditions, at least the .NET Core SDK license and RasterEdge .NET TWAIN Add-On license should be purchased. As one license can only be used by a single named developer, additional licenses should be purchased if more developers will use the product. We also offer server licenses for server deployment. When a license is purchased, you will get the license key by E-mail from us.




Open & Close Connection to Twain Devices C# APIs



The following APIs are used to open and close connection to Twain devices in C#.NET application. Using the Open() method, you can open connection to Twain devices. Using the Close() method, you can close the connection.




void Device.Open();
void Device.Close();





Open & Close Connection to Twain Devices C# Demo Code



Developers can copy the following free sample code to your Visual C#.NET TWAIN image scanning project to open and close connection to Twain devices.




 /// < summary >
/// Before you get and set properties of Twain devices, device connection should be opened.
/// < /summary >
public void OpenAndCloseTwainConnection()
{
   Acquisition acq = new Acquisition();

   acq.AcquireFinished += new EventHandler (OnAcquireFinished);
   Device device = acq.GetAvailbleDevices();

   // Query and set some of the device abilities here.
   TwainStaticFrameSizeType[] frameTypes = device.GetSupportedFrameSizes();
   device.Acquire();
}


private void OnAcquireFinished(object sender, EventArgs e)
{
   this.device.Close();
}