ntwain icon indicating copy to clipboard operation
ntwain copied to clipboard

scanner continues scanning few more pages even after stopping by setting CancelAll to false in TransferReady

Open miroshnandaa opened this issue 2 years ago • 3 comments

I am stopping the scanning by the below code

_twain.TransferReady += (s, ev) => { ev.CancelAll = true; };

this stops the data transfer but still the scanner feeder takes few more pages from Scanner device without sending it to driver.

Is there any way to stop the feeder quickly ?

miroshnandaa avatar May 04 '22 11:05 miroshnandaa

I may have hidden things too well so this call was not made public. Maybe I can expose it in the event.

soukoku avatar May 04 '22 13:05 soukoku

hi @soukoku, that will be great if you can expose it in the event. If you can tell me when you are planning to do it then it will be really really helpful for me

miroshnandaa avatar May 05 '22 01:05 miroshnandaa

I think you can set the number of scans with the CapXferCount property, -1 for continuous scanning and any value for the number of scans and the scanner will stop feeding paper; but for a duplex scanner you need to set it to single-sided scanning mode first, for example my code is as follows:

//set scan number
                if (TwainScanNumberSet.Text != string.Empty && Int32.TryParse(TwainScanNumberSet.Text, out int TwainScanNumberSetInt))
                {
                    if(dataSource.Capabilities.CapXferCount.CanSet)
                    {
                        if(TwainScanNumberSetInt > 0)
                        {
                            //set single scan mode
                            if (dataSource.Capabilities.CapDuplex.IsSupported && !(DoubleScanBox.Checked))
                            {
                                dataSource.Capabilities.CapDuplexEnabled.SetValue(BoolType.False);
                            }
                            dataSource.Capabilities.CapXferCount.SetValue(TwainScanNumberSetInt);
                        }
                        else
                        {
                            dataSource.Capabilities.CapXferCount.SetValue(-1);
                        }
                    }
                }

jidesheng6 avatar Apr 26 '23 06:04 jidesheng6