twain_library icon indicating copy to clipboard operation
twain_library copied to clipboard

how to stop or terminate the scan

Open madeline0528 opened this issue 1 year ago • 16 comments

I use the DTWAIN_AcquireFile api to acquire the image,but I don't want to these images,how do I stop or terminate it?

madeline0528 avatar May 04 '23 12:05 madeline0528

Not clear what you are asking, but if your goal is to stop the feeder, you can set up the application to get the DTWAIN_TN_PAGECONTINUE notification, and return 0 or 2 back to DTWAIN when this notification is sent.

This is not documented fully (will need to update it), but you will see DTWAIN_TN_PAGECONTINUE explained here.

dynarithmic avatar May 04 '23 15:05 dynarithmic

What I mean is that,I want to stop the scanner to acquire images when the images are acquiring,which api should I use?DTWAIN_TN_PAGECONTINUE notification is dtwain triggered,not the user,is that right?

madeline0528 avatar May 05 '23 01:05 madeline0528

Yes, DTWAIN_TN_PAGECONTINUE is sent to the application by DTWAIN. You need to respond to it by returning the desired value. By default (returning a 1), it does nothing, but returning a 0 should act in stopping the scanning process. If returning 0 doesn't reset the scanner, then try returning 2 (which makes a call to stop the feeder directly).

But be aware that stopping the scanner when already set up to scan all (or a set) number of pages is highly dependent on the device as to how it will behave. Some devices may eject all the remaining pages, some will report an error, others may stop right away and report no error. Just be aware of the possible consequences of stopping the scanning process abruptedly.

Also, please state the model of the scanner you are using. This way, I have an idea of what may happen, and address any issues if there are problems.

dynarithmic avatar May 05 '23 04:05 dynarithmic

The production of scanner which I use is HuaGao,and the model of the scanner is one of these:HS-8010Pro、HS-7010Pro、HS-6010Pro、P-5010Pro、Hi-4010Pro、HS-6010Pro、HS-4010Pro、i-5010UW、Hi-5010Pro、i-6010UW、Hi-6010Pro、p-6010pro、HS-6010UW、i-6010P、G-0701W、i-6010Pro

madeline0528 avatar May 06 '23 09:05 madeline0528

I saw the twain pdf,which write:To discard all pending images, use the DG_CONTROL / DAT_PENDINGXFERS / MSG_RESET operation. Does the dtwain support it?

madeline0528 avatar May 06 '23 11:05 madeline0528

The DG_CONTROL / DAT_PENDINGXFERS / MSG_RESET will be automatically done if DTWAIN_TN_PAGECONTINUE is returned 0.

Also, in general, you are free to call any TWAIN triplet by using DTWAIN_CallDSMProc. But this requires that you know exactly what you are doing.

dynarithmic avatar May 06 '23 14:05 dynarithmic

Also, if you eventually want to debug the library source code, basically all of the logic for DTWAIN_TN_PAGECONTINUE is found here.

A notification is sent out, and the return value of 0 issues the ResetTransfer(MSG_RESET)

exactly as mentioned by the TWAIN specification.

dynarithmic avatar May 06 '23 14:05 dynarithmic

Another question: What computer language are you using? Is it C#, C++, etc.?

Also, I made a few changes to the libraries in the development branch. Please test your application using the release versions found here (32-bit) and here (64-bit).

dynarithmic avatar May 06 '23 17:05 dynarithmic

OK,thanks, and I use Javascript

madeline799 avatar May 22 '23 14:05 madeline799

Thanks. I would like to know how you used Javacript with the library. The reason is that unfortunately, I am not a JS expert, and would like to know how you were able to get the library to work with JavaScript.

We currently have Java, C#, Delphi, Python, and a few other languages working with the library, but haven't come up with the interface for JS.

dynarithmic avatar May 22 '23 14:05 dynarithmic

I use the node Library ffi to call the api of dtwail.dll.But I have a question,how do I define these variablesDG_CONTROL / DAT_PENDINGXFERS / MSG_RESET when I use DTWAIN_CallDSMProc.

madeline799 avatar May 22 '23 14:05 madeline799

Ok. I will have to look into ffi.

The TWAIN constants are in twain.h.

DG_CONTROL = 1 DAT_PENDINGXFERS = 5 MSG_RESET = 7

dynarithmic avatar May 22 '23 14:05 dynarithmic

Thanks,and other question is when dtwain api is calling,(for example DTWAIN_AcquireFile )the other api can not be called,do you know the reason?

madeline799 avatar May 22 '23 15:05 madeline799

the other api can not be called

Can you clarify this question? I am not sure what you mean here.

dynarithmic avatar May 22 '23 16:05 dynarithmic

When the DTWAIN_AcquireFile is calling,I use DTWAIN_CallDSMProc to terminate the scanner,but it was not called,I have no idea about it.(The requirement is to stop the scanner if user do not want to scan.)

madeline799 avatar May 23 '23 01:05 madeline799

What verification do you have that the function was not called? The function must have been called, and possibly you are passing in bad application and/or source identity values. What is the return value?

This can also be verified by generating a log (DTWAIN_SetTwainLog) and seeing the call go through to the TWAIN system by looking at the function call and the sequence of steps that occur before returning.

Also, did you try what was suggested earlier? Doing things like stopping the scanner are best done for languages that have callback mechanisms, and I do not know if ffi has such capabiltiies. If not, then you may be stuck.

Finally, the scanners you mentioned are not sold in the part of the world where I am located. The worst case scenario is to get the source code, compile, and debug what is going on.

dynarithmic avatar May 23 '23 07:05 dynarithmic

Closing. Only will reopen if the issue has not been resolved.

dynarithmic avatar Sep 26 '24 02:09 dynarithmic