- This topic has 3 replies, 3 voices, and was last updated 4 years, 9 months ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
Forums › TWAIN Classic › Scanning Multiple Files
I have using pytwain which is twain module for python . I want to scan multiple files . So I put lots of documents on the scanner and it scans all of them . But I can’t get this documents in the program . This is the code:
import twain
sm = twain.SourceManager(0)
ss = sm.OpenSource()
for i in range(3):
ss.RequestAcquire(0,0)
rv = ss.XferImageNatively()
if rv:
(handle, count) = rv
twain.DIBToBMFile(handle, ”{i}.bmp’.format(i))
It gave an error twain.excTWCC_SEQERROR . So how can I do this ?
You’ll have to talk to the folks who wrote and/or maintain pytwain. However, after ss.RequestAcquire() you may only have entered state 5 in the driver. The driver doesn’t go to state 6 until it’s ready to transfer images (indicated by sending MSG_XFERREADY to the application).
While I don’t normally recommend this. One hack would be to loop on rv = ss.XferImageNatively(), as long as you’re getting twain.excTWCC_SEQERROR. That error indicates that you’re still in state 5. When the driver transitions to state 6 you’ll get back some other status, such as TWRC_XFERDONE or TWRC_CANCEL. You’ll need to check for a few different possible returns.
Scanning Multiple Files is very difficult for me
Can you be more specific?