0

I have problem in reading all the pages in the feeder using WIA Library. I have a scanner HP scanjet 5590 , scanning from flat is working perfectly. Scanning from feeder works perfectly if the page in the feeder is only one.

Now if I have more than one page in the feeder, it only scan one page, and it stops while trying to scan the next one.

I think the problem is that it goes to the scanning function only one time. How to keep reading the scan function while there is pages in the feeder?

I used WIA library:

Here is my code for the feeder scanning function:

                if (this._deviceInfo != null)
                {
                    // Connect to the device
                    var device = this._deviceInfo.Connect();

                    //set _adf 
                    _adf = true; 

                    CommonDialog commonDialog = new CommonDialog();

                    var item = device.Items[1];
                    int dpi = 150;

                    // configure item
                    //SetItemIntProperty(ref item, 6146, 2); // greyscale
                    //SetItemIntProperty(ref item, 6147, dpi); // 150 dpi
                    //SetItemIntProperty(ref item, 6148, dpi); // 150 dpi
                    //SetItemIntProperty(ref item, 6151, (int)(dpi * _width)); // scan width
                    //SetItemIntProperty(ref item, 6152, (int)(dpi * _height)); // scan height
                    SetItemIntProperty(ref item, 4104, 8); // bit depth

                    //set Feeder Settings // 1 for ADF, 2 for flatbed
                    int deviceHandling = _adf ? int.Parse(DeviceDocumentHandling.Feeder.ToString()) : int.Parse(DeviceDocumentHandling.FlatBed.ToString()); 

                    // configure device
                    SetDeviceIntProperty(ref device, DEVICE_PROPERTY_DOCUMENT_HANDLING_SELECT_ID, deviceHandling);
                    int handlingStatus = GetDeviceIntProperty(ref device, DEVICE_PROPERTY_DOCUMENT_HANDLING_STATUS_ID);

                    if (handlingStatus == deviceHandling)
                    {
                        //I think I should add a loop here While(scanner had pages?) how to do it? 
                        {
                            //start scan
                            imageFile = commonDialog.ShowTransfer(item, MyFormatID.wiaFormatJPEG, true);

                            // save image to a file and add to arraylist 
                            var path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop);
                            path = Path.Combine(path, Path.GetTempFileName());
                            path = System.IO.Path.ChangeExtension(path, "jpg");
                            imageFile.SaveFile(path);

                            _tempSavedImages.Add(path); //add to arraylist teh created images 
                        }

                    }

                }
Jørgen R
  • 10,568
  • 7
  • 42
  • 59
  • Check out this link: http://stackoverflow.com/questions/11331498/c-sharp-wia-with-automatic-document-feeder-adf-retuns-only-one-page-on-certain – Rachel Apr 14 '14 at 05:42
  • Yes , Thank you. This link solved my problem. I can check now if there is still pages in the feeder. – FloweryCoder Apr 14 '14 at 07:03

0 Answers0