Scan multiple documents at once using separator sheets

Discussions about Automatic Document Recognition in GdPicture.NET.
Post Reply
ilariam
Posts: 3
Joined: Wed Jun 08, 2011 5:02 pm

Scan multiple documents at once using separator sheets

Post by ilariam » Wed May 23, 2012 3:46 pm

Hi,
I need scan multiple documents at once, I put a separator sheet with a known barcode between each documents .
I found this sample:
gdpicture-activex-code-samples/scan-mul ... -t480.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

User avatar
Loïc
Site Admin
Posts: 5597
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Scan multiple documents at once using separator sheets

Post by Loïc » Fri May 25, 2012 11:30 am

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()

ilariam
Posts: 3
Joined: Wed Jun 08, 2011 5:02 pm

Re: Scan multiple documents at once using separator sheets

Post by ilariam » Tue May 29, 2012 4:24 pm

Thanks!
It works!

Ilaria

sriramps
Posts: 2
Joined: Wed Oct 09, 2013 5:16 pm

Re: Scan multiple documents at once using separator sheets

Post by sriramps » Tue Jan 21, 2014 6:10 pm

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?

SamiKharma
Posts: 352
Joined: Tue Sep 27, 2011 11:47 am

Re: Scan multiple documents at once using separator sheets

Post by SamiKharma » Thu Apr 17, 2014 12:57 pm

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

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests