TWAIN ActiveX Control, Plug-in, Scanner SDK, Component, HTTP Control/SDK

Dynamsoft TWAIN Products

Support Community for TWAIN Control/Component/SDK for Scanning Solutions
* Login   * Register
* FAQ    * Search

It is currently Sun May 20, 2012 1:39 pm




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Attempting to scan - Sometimes Causes Fatal Error
PostPosted: Thu Aug 02, 2007 10:24 am 
Offline

Joined: Thu Aug 02, 2007 10:14 am
Posts: 3
Hello Board!

I am new to Dynamic Twain and am trying to get the product to work inside my own program.

Interestingly, I can scan multiple pages in the document feeder on my Brother 420 MFC and 8860 MFC hardware, but my Avision scanners will only scan single pages or the first page of a batch. Once the first page of the batch is scanned, my program fails and closes offering to send a message to Microsoft to report the issue.

I am unsure what to do. I have tried many variations to avoid this:

Here is my code

Private Sub DT1_OnPostTransfer()
Dim myImg As New FileSystemObject
If myImg.FileExists(File1.Path & "\TempImg.chj") Then ' Delete a temporary file
myImg.DeleteFile (File1.Path & "\TempImg.chj")
End If
On Error GoTo Err:
DT1.OpenSource


imgAcq(iAcq).Picture = DT1.Picture ' imgAcq is an array for another idea that I haven't discarded
DT1.SaveAsJPEG (File1.Path & "\TempImg.chj")

If AcquireSaveEach = True Then

If Option1.Value = True Then
DT1.SaveAsJPEG (File1.Path & "\" & Text2.Text & "(" & ai & ")" & ".chj")
End If
If Option2.Value = True Then
DT1.SaveAsBMP (File1.Path & "\" & Text2.Text & "(" & ai & ")" & ".chb")
End If
If Option3.Value = True Then
DT1.SaveAsTIFF (File1.Path & "\" & Text2.Text & "(" & ai & ")" & ".chf")
End If
If Option4.Value = True Then
DT1.SaveAsPNG (File1.Path & "\" & Text2.Text & "(" & ai & ")" & ".chg")
End If
Text2.Text = Replace(Text2.Text, "(" & ai & ")", "")
ai = ai + 1
File1.Refresh
End If
'iAcq = iAcq + 1
If Check2.Value = 1 Then
DT1.IfTiffMultiPage = True
'DT1.IfAutoFeed = True
Command2.Value = True
Else
DT1.IfTiffMultiPage = False
'DT1.IfAutoFeed = False
End If
DT1.CloseSourceManager
loadAspect ' loads the image on screen
Exit Sub
Err:
MsgBox "Error acquiring, please try again.", vbInformation, "Acquisition Error"
End Sub

Thanks for your help.

_________________
www.descriptmed.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 02, 2007 9:07 pm 
Offline
User avatar

Joined: Mon Mar 07, 2005 11:11 pm
Posts: 866
Please modify the following line:
Code:
DT1.OpenSource
to
Code:
DT1.CloseSource

Also, we need more information about your issue. Would you please send the simplified code to TWAINsupport@dynamsoft.com?

Thanks.

_________________
Robert
TWAIN Support Team
http://www.dynamsoft.com/
TWAIN ActiveX/Plug-in HTTP Control/SDK & TWAIN ActiveX Control, Scanner SDK, Component
Software Configuration Management | SCM Solution


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 4:09 am 
Offline

Joined: Thu Aug 02, 2007 10:14 am
Posts: 3
Removing DT1.CloseSourceManager fixed the above problem

However, some scanners react well, others do not. e.g. Brother MFC8860 and MFC 420 will both scan multiple page tiffs and/or single pages saving each as it goes, but Avision will not as well as Fujitsu.

Obviously I am missing something.

_________________
www.descriptmed.com


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 12, 2007 5:51 pm 
Offline
User avatar

Joined: Mon Mar 07, 2005 11:11 pm
Posts: 866
Does your Avision scanner have an Automatic Document Feeder (ADF)? If yes, you can refer to the following code that demonstrates how to use ADF to scan multiple pages and save each page in a separate file.
Code:
Dim iDocumentCounter As Integer

iDocumentCounter = 0 'set initialize value

Private Sub BeginScan()
    Twain1.OpenSource

    Twain1.IfShowUI = False
    Twain1.IfDisableSourceAfterAcquire = True
    If Twain1.Duplex <> 0 Then
        Twain1.IfDuplexEnabled = True 'enable duplex
    End If


    If Twain1.IfFeederEnabled = True Then
         Twain1.XferCount = -1
         Twain1.IfAutoFeed = True 'auto feed

         If Twain1.IfFeederLoaded = True Then
             Twain1.AcquireImage
         End If
    End If

End Sub

Private Sub Twain1_OnPosttransfer()

iDocumentCounter = iDocumentCounter + 1

If Twain1.SaveAsBMP("c:\Image\" + Str(iDocumentCounter) + ".bmp") = False Then
    MsgBox Twain1.ErrorString
End If

End Sub

Thanks.

_________________
Robert
TWAIN Support Team
http://www.dynamsoft.com/
TWAIN ActiveX/Plug-in HTTP Control/SDK & TWAIN ActiveX Control, Scanner SDK, Component
Software Configuration Management | SCM Solution


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 12, 2007 5:53 pm 
Offline

Joined: Thu Aug 02, 2007 10:14 am
Posts: 3
Yes it does! I will give this code a try. Thank you so much.

_________________
www.descriptmed.com


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 12, 2007 6:26 pm 
Offline
User avatar

Joined: Mon Mar 07, 2005 11:11 pm
Posts: 866
:)

_________________
Robert
TWAIN Support Team
http://www.dynamsoft.com/
TWAIN ActiveX/Plug-in HTTP Control/SDK & TWAIN ActiveX Control, Scanner SDK, Component
Software Configuration Management | SCM Solution


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

It is currently Sun May 20, 2012 1:39 pm


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron

Copyright © 2010 Dynamsoft Corporation. All Rights Reserved. | Knowledge Base | Source Control Blog