how to get all scanned papers using twaindotnet

Hi EE,

im using this library here

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.

        ' 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


//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.

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

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

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

OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

Kamal KhaleefaInformation Security SpecialistAuthor Commented:
im getting "1"
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.
Kamal KhaleefaInformation Security SpecialistAuthor Commented:
Hi @CodeCruiser

i try to do but id dint work

finally i install the following library
and it work

thanks for your help

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