C#: Online Guide
How To: Twain SDK
Console Based Scanning
Console Based Scanning
Home ›› XImage.Twain ›› C# Twain: Console Based Scanning

C# TWAIN - Scan Multi-pages into One PDF Document

Easy to Scan Multiple Pages into One PDF/TIFF in C# with .NET TWAIN Toolkit

C# TWAIN: Scan Multi-pages into One PDF/TIFF Overview

It is common to scan multiple pages into a single PDF or TIFF file through C#.NET programming in document imaging world. Using our .NET Imaging SDK and its TWAIN Scanning Add-on, it is so easy to scan many pages into one PDF or TIFF document file in C#.NET application. RETwain, along with REImage can easily be used to accomplish this task. The two most popular multipage image formats are TIFF and PDF, and this C# guide page will concentrate on PDF. Since in RasterEdge Imaging, the TIFFDocument and PDFDocument have common prototype, BaseDocument Class, so the procedure for TIFF is very similar.

Related .net document control helps:
c# asp.net document viewer: ASP.NET Document Viewer Control in C#: View, Annotate, Redact web document files in ASP.NET using C#
asp.net document viewer in c#: EdgeDoc ASP.NET Document Viewer C# Control: Open, view, annotate, redact, convert documents online using ASP.NET Web Con...
c# asp.net iis document viewer: C# HTML5 Viewer: Deployment on IIS
asp.net edit pdf text using c#: ASP.NET PDF Text Edit Control: online edit PDF text content using C# ASP.NET
c# asp.net tiff document viewer: ASP.NET Tiff Document Viewer: view, annotate Tiff files in HTML using C# Control
asp.net redact pdf using c#: ASP.NET Redact PDF Document Control: redact, remove PDF text, images in web browser using C# ASP.NET
c# asp.net azure document viewer: ASP.NET Azure Document Viewer: view, annotate files online using ASP.NET Cloud Service

If you want to use our C#.NET TWAIN SDK to scan and save multiple pages into one PDF or TIFF document through TWAIN acquisition, you need to do three things for preparation. First of all, install .NET Framework 2.0 or later versions on your computer. Then, make Visual Studio 2005 or later versions available. At last, install TWAIN and provide at least one TWAIN compatible device.

On this page, you will find C#.NET document imaging DLLs used for scanning multiple pages into one PDF/TIFF document, key events for this TWAIN scanning, and C#.NET demo code to accomplish this task.

DLLs for C# Console Based TWAIN Scanning

Basically, there are three DLLs, namely RasterEdge.Imaging.Basic.dll, RasterEdge.Imaging.Basic.Codec.dll and RasterEdge.Imaging.TWAIN.dll, should be integrated into your Visual C#.NET Console application to perform advanced TWAIN image scanning in Console application.

C# Sample Code for Console Based TWAIN Scanning

Please use the following C# sample code to have a quick test for Console based TWAIN image scanning. Actually, scanning from the Console is done similarly to scanning in a .NET WinForms application.

public class AcquisitionClass
      static void Main(string[] args)
         Acquisition acquisition = new Acquisition();
         count = 0;
         List<string> names = acquisition.GetAvailbleDevicesName();
         string deviceName = names[0];
         TWAINDevice device = acquisition.GetDevice(deviceName);
         Console.Out.WriteLine("---Beginning Scan---");

         // scan all availble pages
         device.ScanSetting.ShouldTransferAllPages = true;
         Console.Out.WriteLine("---Ending Scan---\n Press Enter To Quit");

      private static void AddEvents(Acquisition acquisition)
            acquisition.ImageAcquired += new ImageAcquiredEventHandler(acquisition_ImageAcquired);
            acquisition.AcquireCompleted += new AcquireCompletedEventHandler(acquisition_AcquireCompleted);
            acquisition.AcquireCanceled += new AcquireCanceledEventHandler(acquisition_AcquireCanceled);

      static void acquisition_AcquireCanceled(object sender, EventArgs args)
            Console.Out.WriteLine("Acqusition Canceled");

      static void acquisition_AcquireCompleted(object sender, AcquireCompletedEventArgs args)
            Console.Out.WriteLine("Acquisition Finished");

      static int count;

      static void acquisition_ImageAcquired(object sender, ImageAcquiredEventArgs args)
            string filename = "out" + count++ + ".tif";

            // save scanned images as PNG
            args.OutputImage.Save(ImageType.PNG, @"c:\"+count+".png");
            Console.Out.WriteLine("Frame " + count + " Acquired. Saved At: " + filename);

In addition to C# guide for Console based TWAIN scanning, RasterEdge also illustrates how to scan many pages into a PDF or TIFF file in C#.NET.