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



Last Go to last post Unread Go to first unread post
#1 Posted : Wednesday, September 20, 2006 9:52:12 AM(UTC)

Groups: Registered
Posts: 7



I am writing an application that needs to scan documents from a TWAIN scanner.  For the most part, I will not know what kind of scanner will be installed on the computer.

I wanted to use FastTWAIN because 2 of our scanners can rip these pages out at 120ipm.

I only need to scan the documents at 150 dpi B&W. 

We are using the application to archive paper medical records to a MS SQL database.

When I started to look into FastTWAIN, I was a little disappointed that you had to scan several batches of documents so it could figure out what configuration was the best.

My app needs to not write anything to the hard drive. 

I have dropped FastTwain for now, but if there is a way to use it without needing to write to a hard drive I would be very interested.

Since I dropped FastTwain, I have gotten lost in the configuration part of using the scanner.  I can select the source and scan images to a RasterImageList.


By default, I want the scanner to give the RasterImageList an image that is 150dpi B&W.

If the scanner has an ADF, then I want to check to see if there is paper in the feeder and then scan.

If the scanner is duplex capable, I want the pages to be scanned duplex.

I also want to auto deskew, remove blank pages, and clean the image up a little.

Our paper types vary greatly from yellow and pink onion paper to regular copier paper so I just want good middle of the road scan settings.


All of this needs to be done through the program if possible.  I do not want the user to make any choices.

Thank you for any help you can provide.



Here is some code showing you my first attempts at setting the scanner configurations:

As you can see, I have commented all of this out.


    Private Sub GetSetScannerConfiguration()


            'Dim twFastConfigs() As TwainFastConfiguration = _twainSession.FindConfiguration(1, TwainTransferMechanism.Memory, 5)

            ''ReDim twFastConfig(1)

            'Dim fastConfigRes As TwainFindFastConfigurationResult


            '_twainSession.EnableFastConfigurationEvent = False


            ''twFastConfig(0).TransferMechanism = TwainTransferMechanism.Memory

            ''twFastConfigs(0).ImageFormat = RasterImageFormat.Tif

            ''twFastConfigs(0).BitsPerPixel = 1

            ''twFastConfig(1).TransferMechanism = TwainTransferMechanism.Native

            ''twFastConfig(1).ImageFormat = RasterImageFormat.Tif

            ''twFastConfig(1).BitsPerPixel = 1


            'fastConfigRes = _twainSession.FindFastConfiguration("d:\temp", TwainFastUserInterfaceFlags.None, 0, 1, twFastConfigs)


            'Dim msg As String

            'MessageBox.Show("FindFastConfig method was successful")


            'msg = String.Format("Result Scan Configs count = {0}", fastConfigRes.Tested.Length)



            'msg = "Transfer Mode = " + CStr(fastConfigRes.Tested(0).TransferMechanism) + Chr(13) + _

            '      "File Format = " + CStr(fastConfigRes.Tested(0).ImageFormat) + Chr(13) + _

            '      "Buffer Size = " + CStr(fastConfigRes.Tested(0).BufferSize) + Chr(13) + _

            '      "Required Time = " + CStr(fastConfigRes.Tested(0).RequiredTime) + Chr(13)

            'MessageBox.Show(msg, "Tested Scan Configurations...")


            'msg = "Transfer Mode = " + CStr(fastConfigRes.Best.TransferMechanism) + Chr(13) + _

            '      "File Format = " + CStr(fastConfigRes.Best.ImageFormat) + Chr(13) + _

            '      "Buffer Size = " + CStr(fastConfigRes.Best.BufferSize) + Chr(13) + _

            '      "Required Time = " + CStr(fastConfigRes.Best.RequiredTime) + Chr(13)

            'MessageBox.Show(msg, "Best Scan Configurations...")



            'Dim capType() As TwainCapabilityType = _twainSession.SupportedCapabilities

            'Dim i As Integer


            'twCap = _twainSession.GetCapability(TwainCapabilityType.ImageBitDepth, TwainGetCapabilityMode.GetValues)

            'For i = 0 To capType.Length - 1

            '    Dim twCap As New TwainCapability

            '    Select Case capType(i)

            '        Case TwainCapabilityType.ImageTransferMechanism

            '            twCap.Information.ContainerType = TwainContainerType.OneValue

            '            twCap.Information.Type = TwainCapabilityType.ImageTransferMechanism


            '            twCap.OneValue.ItemType = TwainItemType.Int32

            '            twCap.OneValue.Value = TwainCapabilityValue.TransferMechanismMemory


            '            _twainSession.SetCapability(twCap, TwainSetCapabilityMode.Set)


            '        Case TwainCapabilityType.Duplex



            '    End Select










            '_twainSession.EnableAutoFeed = True

            '_twainSession.EnableDuplex = True

            '_twainSession.ImageBitsPerPixel = 1

            '_twainSession.XResolution = 150

            '_twainSession.YResolution = 150



        Catch ex As Exception


        End Try

    End Sub



Below is some of the code I already have in place.


   Private Sub ScanImagestoList()



            _twainSession = New Twain.TwainSession

            _twainSession.Startup(Me, "ABCD", "Scanner", "Version 1", " Scanner")










            'enable add and delete buttons

            AddToolStripButton.Enabled = True

            DeleteToolStripButton.Enabled = True



        Catch ex As Exception




        End Try



    End Sub


    Private Sub SelectScanner()

        'if there is only one TWAIN source, it is already selected as the scanner. 

        'This displays the select dialog box only when there are multiple sources


            If _twainSession.SourceInformation.Length > 1 Then

                If _twainSession.SelectSource() <> Windows.Forms.DialogResult.OK Then

                    MessageBox.Show("Error selecting source")

                End If

            End If

        Catch ex As Exception


        End Try

    End Sub



  Private Sub ScanPages()

        If _twainSession.Acquire(TwainUserInterfaceFlags.Modal) <> Windows.Forms.DialogResult.OK Then

            MessageBox.Show("error acquring from source")

        End If

    End Sub


    Private Sub twainSession_AcquirePage(ByVal sender As Object, ByVal e As Leadtools.Twain.TwainAcquirePageEventArgs) Handles _twainSession.AcquirePage



            Dim imageitem As New RasterImageListItem(e.Image, 1, "")



        Catch ex As Exception


        End Try

    End Sub



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.

#2 Posted : Thursday, September 21, 2006 12:33:23 AM(UTC)


Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

When using FastTwain, the only option is to scan to file.

Regarding the capabilties you want to set:

1) Set the ImageBitsPerPixel property to 1 to scan B&W images.
2) Set XResolution and YResolution properties to 150 to scan with 150 DPI.

3) Check the value of DuplexMode to determine if the source supports duplex.  If it does, set EnableDuplex to True to scan in duplex.

4) Set EnableAutoFeed to True to scan from the feeder.

5) Use the DeskewCommand class to deskew the image.

6) There are samples for blank page detection on the forums.  Do a search on the term "blank page".

#3 Posted : Monday, September 25, 2006 6:39:46 AM(UTC)

Groups: Registered
Posts: 7

Thank you for your help.

Is there a good book detailing how to use your Tool Kits?



#4 Posted : Monday, September 25, 2006 10:19:10 PM(UTC)


Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

No, unfortunately, there are no books.  The only resources are the
help files and the forums.  If you can't find the answer in those then you can also send your questions to "support@leadtools.com".

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.157 seconds.