Click here to Skip to main content
Click here to Skip to main content

Document Processing SDK for .NET

, 2 Aug 2012 CPOL
In this article, I’ll show you how to embed document processing, such as image scanning, editing, and uploading, to your .NET application.

Editorial Note

This article is in the Product Showcase section for our sponsors at CodeProject. These reviews are intended to provide you with information on products and services that we consider useful and of value to developers.

Introduction

It’s ideal to get a single yet comprehensive document processing SDK to handle various kinds of scanners, webcams and other devices. And the SDK should help you organize different types of documents, convert them to digital copies and store the documents to the target place(s). Dynamic .NET TWAIN enables you to implement the functions above in the most flexible way.

Compatible with both 32-bit & 64-bit Windows OS, Dynamic .NET TWAIN allows you to acquire images from any devices that are compatible with TWAIN, Windows Image Acquisition (WIA) and USB video device class (UVC). The library is optimized for use in C# and VB.NET. After you acquired images from your device or from your local system, the SDK allows you edit the images and upload them to your local disk, FTP site, web server or database.

Barcode Reader, OCR and Annotation add-ons for Dynamic .NET TWAIN allow you to integrate document processing all-in-one. Barcode Reader SDK is able to detect and read 1-D & 2-D barcode symbols on the scanned documents, such as Code 39, Code 93, Code 128, EAN-8, EAN-13, ITF, UPC-A, UPC-E, Codabar, RSS-14Aztec, DataMatrix, PDF417 and QR Code. OCR add-on accurately performs Optical Character Recognition (OCR) and converts the documents to searchable PDF/text files. The SDK supports recognizing more than 40 languages which include English, Spanish, Arabic, Chinese, etc. If you’d like to try it out, a 30-day free trial is available.

Key Features

  • Compatible with Windows OS (both 32-bit and 64-bit)
  • Capture images from scanners, cameras and other devices compatible with TWAIN, WIA or UVC.
  • Capture live video streams from webcams.
  • Load/Download images from your local folder, web server and/or database.

  • Support for auto document feeder (ADF) and batch scanning.
  • Support for setting and reading device features, such as brightness, resolution, contrast, pixel type, duplex and more.
  • Support for storing and restoring default scanning settings.

  • Edit scanned images, such as, Rotate, Mirror, Flip, Crop, Erase, etc.
  • Zoom in/out a selected image.
  • Support for annotation. Add text, lines, eclipses or rectangles to the scanned document(s).
  • Convert scanned images to searchable PDF/text files.
  • Detect and decode 1-D & 2D barcode symbols.

  • Upload the scanned documents to your local folder, web server, FTP site and/or database.
  • Support for BMP, PNG, JPEG, TIFF and PDF. Multi-page TIFF and PDF are supported as well.
  • Support for SSL to secure the image data transit.

Sample Code

  1. Capture images from your device. With a rich set of properties provided, the whole scanning process is customizable, such as whether to show the user interface of the selected source, duplex scanning, resolution, etc.
    private void AcquireImage()
    {
    //select source     dynamicDotNetTwain.SelectSourceByIndex(Convert.ToInt16(cmbSource.SelectedIndex)); 
           dynamicDotNetTwain.OpenSource();
           dynamicDotNetTwain.IfDisableSourceAfterAcquire = true;
     
           //set the resolution
           dynamicDotNetTwain.Resolution = 300; 
           //set whether to show the user interface of the source
           dynamicDotNetTwain.IfShowUI = chkIfShowUI.Checked;  
           dynamicDotNetTwain.IfFeederEnabled = chkIfUseADF.Checked;
           dynamicDotNetTwain.IfAutoFeed = chkIfUseADF.Checked;
           dynamicDotNetTwain.IfDuplexEnabled = chkDuplex.Checked; 
           if ((dynamicDotNetTwain.Duplex == 0) && (chkDuplex.Checked == true))
           {
               string errorstr = "Current source does not support duplex scan.";
               errorstr += "\r\n";
               txtErrorString.Text = txtErrorString.Text + errorstr;
               chkDuplex.Checked = false;
           }
     
           dynamicDotNetTwain.AcquireImage(); //capture image(s) 
    }
  2. Set the image layout.
    dynamicDotNetTwain.SelectSource();
    //make dynamicDotNetTwain ready for capability negotiation
    dynamicDotNetTwain.OpenSource();  
           
    //set the image layout                   
    if (dynamicDotNetTwain.SetImageLayout(fFrameLeft,fFrameTop,fFrameRight,fFrameBottom) == false) 
    MessageBox.Show(dynamicDotNetTwain.ErrorString, "Error");
     
    dynamicDotNetTwain.IfShowUI = false;
    dynamicDotNetTwain.IfDisableSourceAfterAcquire = true;
    dynamicDotNetTwain.EnableSource();
  3. Set the view mode. You can create two controls, one for the thumbnail, the other for viewing/editing. 
    dynamicDotNetTwainThum.MouseShape = true;
    //set the max number of images can be hold in the control
    dynamicDotNetTwainThum.MaxImagesInBuffer = 100; 
    //set the view mode of the thumbnail. 
    dynamicDotNetTwainThum.SetViewMode(1,3);
     
    dynamicDotNetTwainView.MaxImagesInBuffer = 1;
    dynamicDotNetTwainView.SetViewMode(-1,-1);
    dynamicDotNetTwainView.IfFitWindow = true;
    dynamicDotNetTwainView.MouseShape = false;
  4. Save scanned images to your local folder. Besides PDF as showed in the sample code below, other formats including BMP, JPEG, PNG and TIFF are also supported. You can also upload the images to your web server and database.
    private void TrySavingFile(string fileName)
    {
           if (AlreadyAddedFile(fileName))
           {
                MessageBox.Show("Can't save over one of the source files.");
           }
           else
           {
                //save all scanned images as a multi-page PDF file
                this.dynamicDotNetTwain1.SaveAllAsPDF(fileName); 
           }
    }
  5. Read barcode information from the scanned documents.
    this.textBox1.Text = "";
    Result[] aryResult = this.dynamicDotNetTwain1.ReadBarcode(this.dynamicDotNetTwain1.CurrentImageIndexInBuffer, BarcodeFormat.All);
    StringBuilder strText = new StringBuilder();
    strText.AppendFormat(aryResult.Length + " total barcode" + (aryResult.Length == 1 ? "" : "s") + " found.\r\n");
    for (int i = 0; i < aryResult.Length; i++)
    {
          Result objResult = aryResult[i];
          strText.AppendFormat("      Result " + (i + 1) + "\r\n");
          strText.AppendFormat("      BarcodeFormat: " + objResult.BarcodeFormat.ToString() + "\r\n");
          strText.AppendFormat("      Text read: " + objResult.Text + "\r\n");
     
    }
    this.textBox1.Text = strText.ToString();

Distribution

To distribute the application to your end users, you only need to distribute DynamicDotNetTwain.dll with your application. The DLL file doesn’t need to be registered.

Dynamic .NET TWAIN also supports Xcopy deployment.

The distribution is royalty free.

Get Samples

To try out the above mentioned features by yourself, you can download the 30-day free trial of Dynamic .NET TWAIN below.  The samples can be found in the installation folder of the SDK.
Dynamic .NET TWAIN 30-day Free Trial

If you have any questions, you can contact our support team at nettwain@dynamsoft.com.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Dynamsoft

Canada Canada
Dynamsoft is the leading provider of web/.NET image acquisition SDKs and version control solutions.
www.dynamsoft.com
Group type: Organisation (No members)



Comments and Discussions

 
GeneralMy vote of 5 PinmemberLogan_Ellen11-Sep-12 17:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.141015.1 | Last Updated 2 Aug 2012
Article Copyright 2012 by Dynamsoft
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid