Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, April 13, 2017 8:44:56 AM(UTC)

Roberto  
Roberto

Groups: Registered, Tech Support, Administrators
Posts: 39

Thanks: 2 times
Was thanked: 3 time(s) in 3 post(s)

With LEADTOOLS you would use the TwainSession class to interact with any TWAIN device.

Scanning with LEADTOOLS is as easy as doing the following:

Code:
private TwainSession twnSession;

Code:
//new instance of twain session and subscribe to the acquire page event
twnSession = new TwainSession();
twnSession.Startup(this.Handle, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None);
twnSession.AcquirePage += new EventHandler<TwainAcquirePageEventArgs>(twnSession_AcquirePage);


In the code snippet above we subscribe to the AcquirePage event. This event will fire for each page acquired from the TWAIN source. In this event you have access to the image data. Here you can save the scanned file to disk, display it, apply further processing etc.

Then specify a TWAIN source:

Code:
if (twnSession.SelectSource(string.Empty) != DialogResult.OK) 
    MessageBox.Show("Error Selecting Source");


The following code snippet shows how you can leverage our RasterCodecs to save the scanned document to disk in the AcquirePage event.

Code:
private void twnSession_AcquirePage(object sender, TwainAcquirePageEventArgs e)
{
    try
    {
        using (RasterCodecs codecs = new RasterCodecs())
        {
            RasterImage image = e.Image;
            codecs.Save(image, @"DESTINATION FOR SCANNED IMAGE", RasterImageFormat.Tif, 0);
        }              
    }
    catch (Exception ex)
    {
        MessageBox.Show(this, ex.Message);
    }
}


I have attached a small .NET project that uses LEADTOOLS TWAIN support and ImageViewer control to scan from available TWAIN sources and display the scanned documents in the LEADTOOLS ImageViewer. Please note this project uses LEADTOOLS version 19 and was created using Visual Studio 2017.
File Attachment(s):
DotNet_SimpleScanningApp.zip (11kb) downloaded 806 time(s).


An updated project can be found here: https://www.leadtools.co...from-a-twain-source.html

Edited by moderator Wednesday, December 27, 2023 2:07:34 PM(UTC)  | Reason: Updated

Roberto Rodriguez
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.067 seconds.