MarkH$2007086
MarkH

03/28/2007 :: 16:50

Registered

Hi,

I am evaluating GDPicturePro ActiveX version 3.1 using MS Access 2002.

I need to be able to scan documents of multiple pages into a multipage tiff file.

I am using the code below which works, apart from 1 small problem which occurs after the last page has been scanned.

The command
nImageID = oGdPicture.CreateImageFromTwain(Me.Hwnd)
in the While nImageID<>0 loop, is fine until all pages have been scanned, when it then tries to execute on the final loop (which will set nImageID=0) I get a message back from the TWAIN device telling me that there are no pages in the ADF, which is obviously true as they have already been scanned.

Is there a way round this? Can I check for pages in the ADF without trying to actually scan the page?

The GDIplus.dll version is 5.1.3102.2180 and I am using a Canon ir2800 MFD which uses Network Scangear v2.1 for the TWAIN driver.

Thanks in advance for any assisatnce you can offer.

Mark

Dim oGdPicture As GdpicturePro.cGdPicture
Dim oGdPicture2 As GdpicturePro.cGdPicture
Dim nImageCount As Long
Dim nImageID As Long

Set oGdPicture = GdpicturePro.cGdPicture
Set oGdPicture2 = GdpicturePro.cGdPicture

oGdPicture.SetLicenceNumber ("0012345678910111213141516") 'Demo code version
oGdPicture2.SetLicenceNumber ("0012345678910111213141516") 'Demo code version

oGdPicture.TwainSelectSource (Me.Hwnd)
oGdPicture.TwainSetErrorMessage (False)

If oGdPicture.TwainOpenDefaultSource() Then
nImageCount = 0

oGdPicture.TwainSetAutoFeed (True)
oGdPicture.TwainSetHideUI (True)
oGdPicture.TwainSetCurrentResolution (300)
oGdPicture.TwainSetCurrentPixelType (2) 'RGB
oGdPicture.TwainSetCurrentBitDepth (8) ' 24 bpp

nImageID = oGdPicture.CreateImageFromTwain(Me.Hwnd)

While nImageID <> 0
nImageCount = nImageCount + 1
If nImageCount = 1 Then
Call oGdPicture.TiffSaveAsNativeMultiPage("c:\aquire\db5Form2.tif", 2)
Else
oGdPicture2.TiffAddToNativeMultipage (oGdPicture.GetNativeImage)
oGdPicture.CloseNativeImage
End If

nImageID = oGdPicture.CreateImageFromTwain(Me.Hwnd)
Wend
oGdPicture2.CloseImage (oGdPicture2.GetNativeImage)
oGdPicture.TwainCloseSourceManager (Me.Hwnd)
oGdPicture.TiffCloseNativeMultiPage

Else
MsgBox "can't open default source"
End If
Call oGdPicture.TwainCloseSourceManager(Me.Hwnd)
Set oGdPicture = Nothing
Set oGdPicture2 = Nothing
Loïc$2006306
Loïc

03/28/2007 :: 17:23

Registered

Hi,

You can try to use the SetIndicator method to disable the twain message box.

Please, try this code:




Dim nImageCount As Long
Dim oGdPicture As New Gdpicture.cGdPicture
Dim nImageID As Long

oGdPicture.SetLicenceNumber ("0012345678910111213141516") 'Demo code version

If oGdPicture.TwainOpenDefaultSource() Then
nImageCount = 0

oGdPicture.TwainSetAutoFeed (True) 'Set AutoFeed Enabled
oGdPicture.TwainSetAutoScan (True) 'To achieve the maximum scanning rate
oGdPicture.TwainSetIndicators (False)
oGdPicture.TwainSetHideUI (True)
oGdPicture.TwainSetCurrentResolution (300)
oGdPicture.TwainSetCurrentPixelType (2) 'RGB
oGdPicture.TwainSetCurrentBitDepth (8) ' 24 bpp
nImageID = oGdPicture.CreateImageFromTwain(Me.hWnd)

While nImageID <> 0
nImageCount = nImageCount + 1
If nImageCount = 1 Then
Call oGdPicture.TiffSaveAsNativeMultiPage("c:\aquire\db5Form2.tif", 2)
Else
oGdPicture.TiffAddToNativeMultipage (nImageID)
oGdPicture.CloseImage (nImageID)
End If
nImageID = oGdPicture.CreateImageFromTwain(Me.hWnd)
Wend
oGdPicture.TiffCloseNativeMultiPage
oGdPicture.TwainCloseSourceManager (Me.hWnd)
MsgBox "Done !"
Else
MsgBox "can't open default source, twain state is: " & Trim(Str(oGdPicture.TwainGetState))
End If

Set oGdPicture = Nothing



Best regards,

Loïc
MarkH$2007086
MarkH

03/28/2007 :: 17:39

Registered

Hi Loïc,

Thanks for the quick response.

Using the SetIndicator method removes the progress bar during the scanning but unfortunately does not stop the message box at the end from displaying.

Any other suggestions or is it just a 'feature' of the TWAIN driver that I'm using.

Thanks

Mark
Loïc$2006306
Loïc

03/28/2007 :: 17:55

Registered

Ok,

Could you try to get the returned value of the TwainGetState() method after the first and after the last page ?

what are these values ?


Regards,

Loïc
Loïc$2006306
Loïc

03/29/2007 :: 11:48

Registered

This code will solve your problem.


Dim nImageCount As Long
Dim oGdPicture As New Gdpicture.cGdPicture
Dim nImageID As Long

oGdPicture.SetLicenceNumber ("0012345678910111213141516") 'Demo code version

If oGdPicture.TwainOpenDefaultSource() Then
nImageCount = 0

oGdPicture.TwainSetAutoFeed (True) 'Set AutoFeed Enabled
oGdPicture.TwainSetAutoScan (True) 'To achieve the maximum scanning rate
oGdPicture.TwainSetIndicators (False)
oGdPicture.TwainSetHideUI (True)
oGdPicture.TwainSetCurrentResolution (300)
oGdPicture.TwainSetCurrentPixelType (2) 'RGB
oGdPicture.TwainSetCurrentBitDepth (8) ' 24 bpp
nImageID = oGdPicture.CreateImageFromTwain(Me.hWnd)

While nImageID <> 0
nImageCount = nImageCount + 1
If nImageCount = 1 Then
Call oGdPicture.TiffSaveAsNativeMultiPage("c:\aquire\db5Form2.tif", 2)
Else
oGdPicture.TiffAddToNativeMultipage (nImageID)
oGdPicture.CloseImage (nImageID)
End If
If oGdPicture.TwainGetState >= TWAIN_TRANSFER_READY Then
nImageID = oGdPicture.CreateImageFromTwain(Me.hWnd)
Else
nImageID = 0
End If
Wend
oGdPicture.TiffCloseNativeMultiPage
oGdPicture.TwainCloseSourceManager (Me.hWnd)
MsgBox "Done !"
Else
MsgBox "can't open default source, twain state is: " & Trim(Str(oGdPicture.TwainGetState))
End If

Set oGdPicture = Nothing
MarkH$2007086
MarkH

03/29/2007 :: 15:05

Registered

Hi Loïc

Many thanks for the updated code, works a treat.

Great support!!!

Mark
Loïc$2006306
Loïc

03/29/2007 :: 16:13

Registered

You are welcome

Best regards,

Loïc Carrère
back to forum