Page 1 of 1

Scan multiple documents at once using separator sheets

Posted: Wed May 23, 2012 3:46 pm
by ilariam
Hi,
I need scan multiple documents at once, I put a separator sheet with a known barcode between each documents .
I found this sample:
https://gdpicture.com/forum/viewtopic.p ... t=480.html

So I need help to re-write this code for my version, because I have some problems to find the corresponding methods in my version (8.3.0.5).
Anyone can help me?

thanks!

Best regards,

Ilaria

Re: Scan multiple documents at once using separator sheets

Posted: Fri May 25, 2012 11:30 am
by Loïc
Here a proposal, let me know if you need clarifications.

- This code assumes that the first page in the feeder is a separator sheet.
- This code creates multipage PDF files. You can modify it easily in order to acquire into multipage TIFF files.

Code: Select all

        Dim ImageID As Integer
        Dim TemplateSeparatorID As Integer
        Dim oGdPictureImaging As New GdPictureImaging
        Dim oGdPicturePDF As New GdPicturePDF
        Const MIN_CONFIDENCE As Integer = 92
        Dim pdfCount As Integer = 0

        oGdPictureImaging.TwainOpenDefaultSource(Me.Handle)
        oGdPictureImaging.TwainSetHideUI(True)
        oGdPictureImaging.TwainSetAutoFeed(True)  'Set AutoFeed Enabled
        oGdPictureImaging.TwainSetAutoScan(True) 'To  achieve the maximum scanning rate

        'First STEP: We create a new document identifier template from a scan of the paper separator
        ImageID = oGdPictureImaging.TwainAcquireToGdPictureImage(Me.Handle)
        TemplateSeparatorID = oGdPictureImaging.ADRCreateTemplateFromGdPictureImage(ImageID)
        oGdPictureImaging.ReleaseGdPictureImage(ImageID)

        'Step 2, Now we will scan all the document feeder into several PDF files (a new PDF is created if a paper separator is detected)
        oGdPicturePDF.NewPDF()
        Do
            ImageID = oGdPictureImaging.TwainAcquireToGdPictureImage(Me.Handle)
            If ImageID <> 0 Then
                Dim CloserTemplateID As Integer = oGdPictureImaging.ADRGetCloserTemplateForGdPictureImage(ImageID)

                If CloserTemplateID = TemplateSeparatorID AndAlso oGdPictureImaging.ADRGetLastConfidence >= MIN_CONFIDENCE Then
                    'A paper separator has been detected, we start saves & start a PDF
                    If oGdPicturePDF.GetPageCount > 0 Then
                        pdfCount += 1
                        oGdPicturePDF.SaveToFile("output" + pdfCount.ToString() + ".pdf")
                        oGdPicturePDF.CloseDocument()
                        oGdPicturePDF.NewPDF()
                    End If
                Else
                    oGdPicturePDF.AddImageFromGdPictureImage(ImageID, False, True)
                End If

                oGdPictureImaging.ReleaseGdPictureImage(ImageID)
            End If
        Loop While oGdPictureImaging.TwainGetState > TwainStatus.TWAIN_SOURCE_ENABLED

        If oGdPicturePDF.GetPageCount > 0 Then 'Saves the latest PDF, if any
            pdfCount += 1
            oGdPicturePDF.SaveToFile("output" + pdfCount.ToString() + ".pdf")
            oGdPicturePDF.CloseDocument()
        End If

        Call oGdPictureImaging.TwainCloseSource()

Re: Scan multiple documents at once using separator sheets

Posted: Tue May 29, 2012 4:24 pm
by ilariam
Thanks!
It works!

Ilaria

Re: Scan multiple documents at once using separator sheets

Posted: Tue Jan 21, 2014 6:10 pm
by sriramps
I tried the solution. It never worked. The first page is the separator sheet, but the program doesn't recognize it every time.
Do I need to use separator sheet that can be understood by a scanner? or any page that can act as separator sheet?

Re: Scan multiple documents at once using separator sheets

Posted: Thu Apr 17, 2014 12:57 pm
by SamiKharma
Hi,

Any page can be understood as a separator sheet. That being said. if your page has low dpi, or very little spacial information, i.e just text, it will probably fail
Could you attach the page that you mentioned as a separator sheet and the following pages that are failed to be recognized?

Best,
Sami