Guide for C#
Scan Document into TIFF File
Core Document Formats
Additional Features

C# Imaging - Tutorial: Scan Document into TIFF

C# Code to Capture and View Document with a Scanning Client

Visual C#
Home > .NET Imaging SDK > C# > Tutorial: Scan Document into TIFF
If this is your first time to use our DocImageSDK, we strongly suggest you reading How to Start first!

RasterEdge .NET Imaging Web Document Viewer SDK empowers Visual .NET developers and end-users to quickly and easily build individual document management solutions that meet all your needs with our reasonable licensing and comprehensive document viewer controls.
Related .net document control helps: document viewer open source: EdgeDoc:ASP.NET Document Viewer C# Control: Open, view, annotate, redact, convert documents online in C#, VB.NET, AS...
c# text file viewer: ASP.NET Text file viewer in MVC, WebForms: Open, view, annotate, convert txt files in C# ASP.NET
c# word document viewer: ASP.NET Office Word Document Viewer: view Word doc files online using C# in ASP.NET MVC web applications pdf document viewer c#: ASP.NET PDF Document Viewer in C#: open, display, view, annotate, redact Adobe PDF files online in ASP.NET MVC & WebForm... edit pdf text using c#: ASP.NET PDF Text Edit Control: online edit PDF text content using C# ASP.NET
c# tiff viewer: ASP.NET Tiff Viewer: view, annotate multipage Tiff images in ASP.NET MVC, WebForms using C# Control
c# mvc document viewer: ASP.NET Document Viewer using C#: Open, View, Annotate, Redact, Convert document files in ASP.NET using C#, HTML5, JQuer...
As we know, in any web-based document management application, the capture piece is always installed on the client as browsers cannot interface directly with peripherals such as scanners without elevated security. This tutorial builds a Windows Forms application that can be deployed via an MSI installer or .NET Click-Once deployment.
C#.NET Document Scanning Features
  • Completely integrated with RasterEdge Document Viewer DLL
  • Create the document viewer in C#.NET Windows application project
  • Customize your document viewer interface by using C# class
  • C# code to add tool strip controls to the document viewer
  • Quickly open a multi-page document from a the local file
  • Save a the customized multi-page document to a file in C#.NET class
  • Capture documents from a scanner with easy-to-use APIs
C# Code to Capture and View Documents
Following guide will take you through setting up a C#.NET Windows project to embed RasterEdge .NET Imaging Document Viewer DLL and create your own document viewer to capture a multi-page document (including PDF, TIFF, Word and DICOM) from a scanner.

Create the Windows Forms Project

  1. Open Visual Studio 2005 and greater version;
  2. In Visual Studio, create a new C#.NET Windows Forms application.

Customize C#.NET User Document Interface

  1. Add the relative RasterEdge .NET Imaging references to your C#.NET project;
    • RasterEdge.Imaging.TWAIN.dll
    • RasterEdge.Imaging.Basic.dll
    • RasterEdge.Imaging.WebViewer.dll
  2. Drag Visual Studio Toolbox to add a ToolStrip control to the top of the form;
  3. Drag a DocumentViewer control from the Visual Studio Toolbox RasterEdge DocImage tab which can enable user to open, view, navigate and save multi-page document;
  4. Select Fill from the Dock property located in the property grid of the DocumentViewer control to resize the form and controls;
  5. Drag an Acquisition Component from same DocImage tab in the toolbox.

How to Add Toolstrip Controls

Use your added toolstrip control to interact with your application. Please refer to following steps to create the toolstrip:
  1. Choose ComboBox from the Add ToolStripButton pull-down menu. The ComboBox is needed for the Choose a scanner control;
  2. Choose Button to add each new command to the existing controls;

Open a Multi-Page Document From File

After finishing creating users interface, please do as following tips and codes.
  1. Add following using statements to the form as shown below. This prevents you from having to declare the entire namespace for each class reference;
    using System.IO;
    using RasterEdge.Imaging;
    using RasterEdge.Imaging.Codec;
    using RasterEdge.Twain;

  2. Drag an OpenFileDialog from the Visual Studio Toolbox to your form, and double click the button;
  3. Add the following code in the event handler:
    private void tsbOpen_Click(object sender, EventArgs e)
    if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
    documentViewer1.Load(new FileSystemImageSource(new string[] {
    openFileDialog1.FileName }, true), null);
  4. After opening the multiple pages document, use the toolstip to open, view and navigate the pages of any supported image format.

AutoZoom and Image Scaling in C#.NET

Please refer to following C# demo code to do image zooming and scaling.
private void tsbFitToWidth_Click(object sender, EventArgs e)
documentViewer1.ImageControl.AutoZoom =
private void tsbFullSize_Click(object sender, EventArgs e)
documentViewer1.ImageControl.AutoZoom =
documentViewer1.ImageControl.Zoom = 1.0;

C# code to Save a Multi-Page Document

Drag a SaveFileDialog from the Visual Studio Toolbox to your form, and use the save methods to store the multi-page document.
private void tsbSave_Click(object sender, EventArgs e)
if (saveFileDialog1.ShowDialog(this) == DialogResult.OK)
documentViewer1.Save(saveFileDialog1.FileName, new TiffEncoder());

C# Code to Capture Documents from a Scanner

Please follow below c# code to add the capability of capturing documents from a scanner to your C#.NET application.
private void acquisition1_ImageAcquired(object sender, AcquireEventArgs

Choose a Scanner in C# Code

As there may have more than one TWAIN devices configured on the system and the default device may not is the best one for users for capturing the document. Uses should populate the drop-down box previously added to the ToolStrip with all the TWAIN drivers configured on the current system. This enables users to select the device from which images are scanned.
  1. Change the DropDownStyle property in the tcbChooseScanner control to DropDownList;
  2. Add code to populate the drop-down menu with the names of all configured scanners.
public Form1()
if (acquisition1.SystemHasTwain)
foreach (Device dev in acquisition1.Devices)
if (acquisition1.Devices.Count > 0)
tcbChooseScanner.SelectedItem =
tcbChooseScanner.Enabled = false;
tsbScan.Enabled = false;

Recommend this to Google+ is professional provider of ASP.NET MVC Document Viewer, ASP.NET PDF Viewer, MVC PDF Viewer document, content and imaging solutions, available for ASP.NET AJAX, Silverlight, Windows Forms as well as WPF. We are dedicated to provide powerful & profession imaging controls, PDF document, image to pdf files and components for capturing, viewing, processing, converting, compressing and stroing images, documents and more.

©2000-2023 Raster