C#: Online Guide
How To: Twain SDK
Specify Size and Location to Scan
Specify Size and Location to Scan
  |  
Home ›› XImage.Twain ›› C# Twain: Specify Size and Location to Scan

C# TWAIN - Specify Size and Location to Scan


How to Save Acquired Image to File in C#.NET with TWAIN Add-on




C# TWAIN Image Acquisition Application



This C#.NET TWAIN image acquiring library add-on owns the ability to specify developer's need to define the scanning size and location using Visual C# .NET programming language. c# best tiff compression, pdf editor in c#, tesseract c# pdf, pdf sdk vb.net, c# excel to pdf open source, create barcode 128 c#. This online article will illustrate how to determine C# TWAIN image scanning area and location with a series of C# demo codes.


Related .net document control helps:
asp.net excel viewer: ASP.NET Excel Viewer in C# Control (MVC & WebForms): view Office Excel document in web browser.
asp.net annotate pdf: ASP.NET Annotate PDF Control: annotate, comment, markup PDF document online using ASP.NET C#
asp.net document viewer c#: ASP.NET Document Viewer using C#: Open, View, Annotate, Redact, Convert document files in ASP.NET using C#, HTML5, JQuer...
asp.net document viewer: EdgeDoc:ASP.NET Document Viewer C# Control: Open, view, annotate, redact, convert documents online in C#, VB.NET, AS...
asp.net pdf editor: EdgePDF: ASP.NET PDF Editor Web Control: Online view, annotate, redact, edit, process, convert PDF documents
asp.net pdf viewer: ASP.NET PDF Viewer Control: view, navigate, zoom Adobe PDF document in C# ASP.NET
asp.net mvc document viewer: ASP.NET MVC Document Viewer: view, annotate, redact files on ASP.NET MVC web projects




Preparation for Setting C# TWAIN Scanning Size & Location



The preparation of setting C# TWAIN image scanning size and location contains two parts. One is the system developing environment and the other is the C# TWAIN scanning application requirements. vb.net pdf to word, itextsharp read pdf fields vb.net, c# create pdf with password, vb.net modify pdf file, edit pdf file using itextsharp c#, how to convert pdf to word document using c#, add text to pdf vb.net.


System Requirements for C# TWAIN Image Scanning


To make sure that RasterEdge C# TWAIN image scanning library SDK can work stably and successfully in your C# imaging application, please meet following developing requirements first. asp net view word document in browser, pdf preview in asp.net c#, asp.net pdf viewer control, asp.net tiff viewer, asp net remove image from pdf, asp net mvc 5 pdf viewer, asp.net pdf writer.


  Have installed .NET Framework 2.0, 3.0, 3.5, 4.0 or 4.5


  Have installed Microsoft Visual Studio 2005, 2008, 2010 or 2012


  Have installed TWAIN


  Have installed RasterEdge C# TWAIN image scanning SDK


  Have installed at least one TWAIN compatible device


  Have put valid developing license key at the right place

Application Requirements for C# TWAIN Image Scanning


After you meet above mentioned system requirements, then you have to ensure that you have finished following tasks.


  Get the Device object of source TWAIN device. To view detailed C# programming guidance, please follow this link to C# TWAIN Device object creation


  Open a connection to target Device object. Detailed Visual C# .NET demo code for setting TWAIN device connection can be found at this tutorial page of how to open & close connection to TWAIN device




How to Set C# TWAIN Scanning Size & Location



C# TWAIN image scanning control add-on owns the capacity to help developers define where the TWAIN scanning will start and how much area will the image scanning process cover. Just as is mentioned in above section, please make sure you have opened a connection to source Device object.


Note: RasterEdge defines each TWAIN compatible device as a Device object, which can be only created through methods offered by Acquisition class (constructor for TWAIN image acquisition). And each Device object contains APIs that control various TWAIN device capabilities.


If you are a VB.NET developer, you may see online tutorial for Setting Image Size and Location in VB.NET TWAIN Scanning Project.




C# Demo Code to Set TWAIN Image Scanning Size



Using this TwainStaticFrameSizeType method, you can get a list of available frames supported by target TWAIN device in C# project. Then you can choose one that fits your TWAIN image scanning need.




/// <summary>
/// suppose the device is opened
/// </summary>
public void SpecifySizeToScan(Device device)
{
   // Get a list of supported frames and choose the one that fits your needs.
   TwainStaticFrameSizeType[] frames = device.GetSupportedFrameSizes();
   foreach (TwainStaticFrameSizeType frame in frames)
   {
      if (frame == TwainStaticFrameSizeType.LetterUS)
         {
            this.device.FrameSize = frame;
            break;
         }
   }
}





C# Demo Code to Customize TWAIN Scanning Area & Location



Following sample C# code can help you decide the TWAIN image scanning size and location at a time. Using TwainUnitType method, you can get a collection of supported measurement units. Then you can choose your desired measurement unit. After decide the measurement unit, you can accurately determine the TWAIN image scanning area by calling the RectangleF method.




/// <summary>
/// suppose the device is already opened
/// </summary>
/// <param name="device"></param>
public void SpecifyLocationAndSizeToScan(Device device)
{
   device.Units = UnitType.Inches;
   if (device.Units != TwainUnitType.Inches) return;
   device.Frame = new System.Drawing.RectangleF(0, 0, 8.5, 11);
}