HOME

&& Acquire multiple images to multipage tiff from the automatic document feeder of a twain device using vb and GdTwain Pro SDK
&& Download the last version of GdTwain PRO SDK at http://www.gdpicture.com/download/download-gdtwainpro.php



  
Dim nImageCount As Long
Dim nImageID As Long
Dim twain As Object

Set oTwain = CreateObject("gdtwainpro2.twain")

oTwain.SetLicenseNumber ("0012345678910111213141516") 'Demo code version

If oTwain.TwainOpenDefaultSource() Then
   nImageCount = 0
   oTwain.TwainSetHideUI(True)
   oTwain.TwainSetAutoFeed (True) 'Set AutoFeed Enabled
   oTwain.TwainSetAutoScan (True) 'To  achieve the maximum scanning rate
   oTwain.TwainSetCurrentResolution (200)
   oTwain.TwainSetCurrentPixelType (TWPT_BW) 'BW
   oTwain.TwainSetCurrentBitDepth (1) ' 1 bpp

   While oTwain.TwainAcquireToGdPictureImage(Me.hWnd) <> 0
         nImageID = oTwain.GetNativeImage
         nImageCount = nImageCount + 1
         If nImageCount = 1 Then
            Call oTwain.TiffSaveAsNativeMultiPage(App.Path & "\multipage.tif", 4)
         Else
            oTwain.TiffAddToNativeMultipage (nImageID)
            oTwain.CloseImage (nImageID)
         End If
   Wend

   oTwain.TiffCloseNativeMultiPage
   oTwain.TwainCloseSource
   MsgBox "Done !"

Else
   MsgBox "can't open default source, twain state is: " & Trim(Str(oTwain.TwainGetState))
End If