How to scan multiformat multipage document at once time

Example requests & Code samples for GdPicture Toolkits.
Post Reply
davids
Posts: 7
Joined: Wed May 07, 2008 8:15 am
Location: Jakarta, Indonesia
Contact:

How to scan multiformat multipage document at once time

Post by davids » Wed May 07, 2008 9:58 am

How to scan multipage document then save the result as multipage PDF and multipage TIFF at once time :?:
Thank you :)

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

Re: How to scan multiformat multipage document at once time

Post by Loïc » Fri May 09, 2008 12:02 pm

Hi,

A vb sample using GdPicture Pro ActiveX:

Code: Select all

Dim nImageID As Long
Dim nImageCount As Long
   
   Imaging1.TwainSelectSource
   If Imaging1.TwainOpenDefaultSource() Then
      Imaging1.TwainSetAutoFeed (True)  'Set AutoFeed Enabled
      Imaging1.TwainSetAutoScan (True) 'To  achieve the maximum scanning rate
     
      Imaging1.TwainSetCurrentResolution (300)
      Imaging1.TwainSetCurrentPixelType (TWPT_RGB) 'RGB
      Imaging1.TwainSetCurrentBitDepth (8) ' 24 bpp
      Imaging1.TwainPdfStart ("output.pdf")
     
      nImageCount = 0
      While Imaging1.CreateImageFromTwain(Me.hWnd) <> 0
            nImageCount = nImageCount + 1
            nImageID = Imaging1.GetNativeImage
           
            'Saves to native pdf
            Call Imaging1.TwainAddGdPictureImageToPdf(nImageID)
           
            'Saves to native multipage tiff image
            If nImageCount = 1 Then
               Call Imaging1.TiffSaveAsNativeMultiPage("output.tif", CompressionLZW)
            Else
               Call Imaging1.TiffAddToNativeMultiPage(nImageID)
               Imaging1.CloseImage (nImageID)
            End If
      Wend
     
      Imaging1.TwainPdfStop
      Imaging1.TiffCloseNativeMultiPage
      Call Imaging1.TwainCloseSource
      MsgBox "Done !"
   Else
      MsgBox "can't open default source, twain state is: " & Trim(Str(Imaging1.TwainGetState))
   End If

davids
Posts: 7
Joined: Wed May 07, 2008 8:15 am
Location: Jakarta, Indonesia
Contact:

Re: How to scan multiformat multipage document at once time

Post by davids » Mon May 12, 2008 9:30 am

hi Loic,
how to combine it with blank page discard function in this routine
i have try the discard blank page sample but always fail
may you can help me fix this
thank a lot
:D

davids
Posts: 7
Joined: Wed May 07, 2008 8:15 am
Location: Jakarta, Indonesia
Contact:

Re: How to scan multiformat multipage document at once time

Post by davids » Mon May 12, 2008 12:10 pm

hi loic,
i am sorry but i think your sample code is not working :(
i has use the code as same as your sample :?
i also modify the sample code :roll:
the code can't scan multipage multi format documents properly :cry:
it's also can't discard the blank page so can you help me to fix it :?:
the code also often hung or stoped and i have to close it :?:
this is the code that i use

Code: Select all

   Dim nImageID As Long
   Dim nImageCount As Long
   
   If Imaging1.TwainOpenDefaultSource() Then
      Imaging1.TwainSetAutoFeed (True)  'Set AutoFeed Enabled
      Imaging1.TwainSetAutoScan (True) 'To  achieve the maximum scanning rate
      Imaging1.TwainSetHideUI (True) 'To hide the twain user interface
      Imaging1.TwainSetCurrentResolution (200)
      Imaging1.TwainSetCurrentPixelType (TWPT_RGB) 'RGB
      Imaging1.TwainSetCurrentBitDepth (8) ' 24 bpp
      Imaging1.TwainPdfStart ("c:\output.pdf") 'pdf output
     
      nImageCount = 0
      While Imaging1.CreateImageFromTwain(Me.hWnd) <> 0
            nImageCount = nImageCount + 1
            nImageID = Imaging1.GetNativeImage
            if Imaging1.IsBlank(98) = True Then
                Call Imaging1.CloseImage(nImageID)
             Else
                'Saves to native multipage tiff image
                If nImageCount = 1 Then
                    Call Imaging1.TiffSaveAsNativeMultiPage("c:\output.tif", CompressionLZW) 'tif output
                Else
                    Call Imaging1.TiffAddToNativeMultiPage(nImageID)
                End If
                
                'Saves to native pdf
                Call Imaging1.TwainAddGdPictureImageToPdf(nImageID)
                Imaging1.CloseImage (nImageID)
            End If
      Wend
     
      Imaging1.TwainPdfStop
      Imaging1.TiffCloseNativeMultiPage
      Call Imaging1.TwainCloseSource
   Else
      MsgBox "can't open default source, twain state is: " & Trim(Str(Imaging1.TwainGetState))
   End If
the result of tif file only contain the first page from multipage :?
the pdf result contain the whole blank pages :?
for the blank pages - how to discard them :?:
and for the compression i prefer to use jpeg for all format - is it avaiable or not :?:
how to use the jpeg compression for all format :?:
which code part that incorrect :?:
which code part that i have to change or modify :?:
please reply as soon as possible i am really need it :D
thank you very much 8) [/color]

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

Re: How to scan multiformat multipage document at once time

Post by Loïc » Mon May 12, 2008 12:47 pm

Hi,

I've updated the code above.

Now, I give you another version to discard blank pages:

Code: Select all

   Dim nImageID As Long
   Dim nImageCount As Long
   
   Imaging1.TwainSelectSource
   If Imaging1.TwainOpenDefaultSource() Then
      Imaging1.TwainSetAutoFeed (True)  'Set AutoFeed Enabled
      Imaging1.TwainSetAutoScan (True) 'To  achieve the maximum scanning rate
     
      Imaging1.TwainSetCurrentResolution (300)
      Imaging1.TwainSetCurrentPixelType (TWPT_RGB) 'RGB
      Imaging1.TwainSetCurrentBitDepth (8) ' 24 bpp
      Imaging1.TwainPdfStart ("c:\output.pdf")
     
      nImageCount = 0
      While Imaging1.CreateImageFromTwain(Me.hWnd) <> 0
            If Not Imaging1.IsBlank(98) Then
               nImageCount = nImageCount + 1
               nImageID = Imaging1.GetNativeImage
           
               'Saves to native pdf
               Call Imaging1.TwainAddGdPictureImageToPdf(nImageID)
           
               'Saves to native multipage tiff image
               If nImageCount = 1 Then
                  Call Imaging1.TiffSaveAsNativeMultiPage("c:\output.tif", CompressionLZW)
               Else
                  Call Imaging1.TiffAddToNativeMultiPage(nImageID)
                  Imaging1.CloseImage (nImageID)
               End If
            End If
      Wend
     
      Imaging1.TwainPdfStop
      Imaging1.TiffCloseNativeMultiPage
      Call Imaging1.TwainCloseSource
      MsgBox "Done !"
   Else
      MsgBox "can't open default source, twain state is: " & Trim(Str(Imaging1.TwainGetState))
   End If

Best regards,

Loïc

davids
Posts: 7
Joined: Wed May 07, 2008 8:15 am
Location: Jakarta, Indonesia
Contact:

Re: How to scan multiformat multipage document at once time

Post by davids » Tue May 13, 2008 11:11 am

hello Loic, :)
the example is working fine to handle multipage documents otherwise
i am sorry that your new example not working to handle the blank pages :(
there are still blank pages included in the scan results :?
it might cause by the IsBlank method that fail to handle the blank pages :?
is there need some modification to make the code work proper :?:
i am really have no idea why this still exist i am use your code in vb6 sp6 and with fujitsu fi-5120c :cry:
i am also found that the file size too big maybe this couse by the file compression :(
i am try to make the result with low file size without compromising the quality :wink:
maybe i am need the better compression method to handle this :idea:
could you provide the example for other file compression method maybe jpeg :?:
thank you very much for the helps and attentions 8)

regards,
david sugandi

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

Re: How to scan multiformat multipage document at once time

Post by Loïc » Tue May 13, 2008 11:23 am

Hi,

You can try to decrease the value of the threshold parameter of the IsBlank() method: https://www.gdpicture.com/guides/gdpicture/v5/gdpictur ... Blank.html

Loïc

davids
Posts: 7
Joined: Wed May 07, 2008 8:15 am
Location: Jakarta, Indonesia
Contact:

Re: How to scan multiformat multipage document at once time

Post by davids » Tue May 13, 2008 12:00 pm

yes the code work proper
but how about the file compression method
i need the file compression for both tiff and pdf
combine in the previous code
thank you

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

Re: How to scan multiformat multipage document at once time

Post by Loïc » Tue May 13, 2008 12:05 pm

All is into the documentation Davis.

See the different mode of compression available and try they: https://www.gdpicture.com/guides/gdpicture/v5/gdpictur ... iPage.html

Loïc

davids
Posts: 7
Joined: Wed May 07, 2008 8:15 am
Location: Jakarta, Indonesia
Contact:

Re: How to scan multiformat multipage document at once time

Post by davids » Tue May 13, 2008 12:31 pm

yeah, i already try them but it not fit with my need
the file compression still made the result in big size
i try the all compression that described in the documentation
so might you tell me the other compression method
maybe like jpeg or else
thank you

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

Re: How to scan multiformat multipage document at once time

Post by Loïc » Wed May 14, 2008 10:28 am

Hi,

If you want to compress as jpeg you have to use the SaveAsJpeg() method.

Please, check the documentation at "Save and Close Image", it describe all the image formats and compressions you can use.

Best regards,

Loïc

davids
Posts: 7
Joined: Wed May 07, 2008 8:15 am
Location: Jakarta, Indonesia
Contact:

Re: How to scan multiformat multipage document at once time

Post by davids » Wed May 14, 2008 1:34 pm

Loic,
thank very much :)
best regards,
david sugandi

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest