how to get all scanned papers using twaindotnet

Hi EE,

im using this library here
https://github.com/tmyroadctfig/twaindotnet

to scan papers from the scanner

my problem that the code is only showing the last paper was scanned

how i can get all the images being scanned

this code below is from the library

    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Twain needs a hook into this Form's message loop to work:
        twain = New Twain(New WinFormsWindowMessageHook(Me))

        ' Add a handler to grab each image as it comes off the scanner
        AddHandler twain.TransferImage,
            Sub(sender As Object, args As TwainDotNet.TransferImageEventArgs)

                Dim pics As System.Drawing.Bitmap = args.Image

                If (Not (args.Image Is Nothing)) Then
                    pictureBox1.Image = args.Image

                    images.Add(args.Image)

//here it only shows last image
                   

                    widthLabel.Text = String.Format("Width: {0}", pictureBox1.Image.Width)
                    heightLabel.Text = String.Format("Height: {0}", pictureBox1.Image.Height)
                End If
            End Sub

        ' Re-enable the form after scanning completes
        AddHandler twain.ScanningComplete,
            Sub(sender As Object, e As TwainDotNet.ScanningCompleteEventArgs)
                Enabled = True
                

              

            End Sub

       

    End Sub

Open in new window


please help how to get all the scanned images
LVL 16
Kamal KhaleefaInformation Security SpecialistAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CodeCruiserCommented:
TransferImage is called every time a new image is scanned. You set the image in the same picture box so its obvious that it will only show the last image. You need to have multiple pictureboxes or use an image array/collection.
0
Kamal KhaleefaInformation Security SpecialistAuthor Commented:
i did all of that.

but in the library itself they mention that you need to write a code to capture all images since now only last image is transferred.

see the link
https://github.com/tmyroadctfig/twaindotnet/blob/master/src/TestVb/MainForm.vb

also i have traced the code and debug every single line. only last image is being transferred

Thanks
0
CodeCruiserCommented:
The code example uses a List of Image objects to store all the images. So it should have captured all images in that list. What do you get if you use

MessageBox.Show(images.Count)
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Kamal KhaleefaInformation Security SpecialistAuthor Commented:
im getting "1"
0
CodeCruiserCommented:
That is strange. How many are you scanning? Try moving the TransferImage sub to a separate function and then set a breakpoint to see how many times it is being invoked.
0
Kamal KhaleefaInformation Security SpecialistAuthor Commented:
Hi @CodeCruiser

i try to do but id dint work

finally i install the following library
http://sourceforge.net/projects/twainforcsharp/
and it work

thanks for your help
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kamal KhaleefaInformation Security SpecialistAuthor Commented:
i find the solution by installing

http://sourceforge.net/projects/twainforcsharp/
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.