From: David on 10 Nov 2009 08:27 Hi, I'm also using the Fujitsu fi-5120C scanner and have come across the same problem as you whereby the value for the Document Handling Status property (3087) stays at 5 regardless of paper being in the feeder or not. Did you ever manage to resolve the problem? Thanks. Tom G. wrote: How to write C# program using WIA Automation 2.0 to support Multi Feed Scanner 01-Mar-08 I am working on a project right now that needs to be able to scan in multiple pages using a scanner's multi feed feature. The scanner that I am using to test is Fujitsu fi-5120C. I am coding this project in C# and am trying to use WIA Automation 2.0 Library. I am open to alternative technologies if someone has any suggestions. My test case is that I have three sheets of paper in the document feeder and I want my code to scan in all three pages at once. All the pages get scanned correctly when I call the following code: private void CallScanWizard() { WIA.CommonDialog dlg = new WIA.CommonDialog(); Device dvc = dlg.ShowSelectDevice(WiaDeviceType.ScannerDeviceType,true,false); if (dvc != null) { dlg.ShowAcquisitionWizard(dvc); } } This tells me that it is possible in WIA. However, this can't be the solution for me. I don't want the user to have to pick a file path for the images to be saved to. I want to work with them in memory only. So I tried the following code: private const int WIA_DPS_DOCUMENT_HANDLING_SELECT_FEEDER = 1; private const int WIA_DPS_DOCUMENT_HANDLING_SELECT_FLATBED = 2; private const int WIA_IPS_PAGES = 3096; private const int WIA_DPS_DOCUMENT_HANDLING_STATUS_FEED_READY = 1; private const int WIA_PROPERTIES_WIA_RESERVED_FOR_NEW_PROPS = 1024; private const int WIA_PROPERTIES_WIA_DIP_FIRST = 2; private const int WIA_PROPERTIES_WIA_DPA_FIRST = WIA_PROPERTIES_WIA_DIP_FIRST + WIA_PROPERTIES_WIA_RESERVED_FOR_NEW_PROPS; private const int WIA_PROPERTIES_WIA_DPC_FIRST = WIA_PROPERTIES_WIA_DPA_FIRST + WIA_PROPERTIES_WIA_RESERVED_FOR_NEW_PROPS; private const int WIA_PROPERTIES_WIA_DPS_FIRST = WIA_PROPERTIES_WIA_DPC_FIRST + WIA_PROPERTIES_WIA_RESERVED_FOR_NEW_PROPS; private const int WIA_PROPERTIES_WIA_DPS_DOCUMENT_HANDLING_STATUS = WIA_PROPERTIES_WIA_DPS_FIRST + 13; private const int WIA_PROPERTIES_WIA_DPS_DOCUMENT_HANDLING_SELECT = WIA_PROPERTIES_WIA_DPS_FIRST + 14; private const string WIA_DPS_DOCUMENT_HANDLING_STATUS_STR = "Document Handling Status"; private const double WIA_ERRORS_BASE_VAL_WIA_ERROR = 2149646336; private const double WIA_ERRORS_WIA_ERROR_PAPER_EMPTY = WIA_ERRORS_BASE_VAL_WIA_ERROR + 3; private const int WIA_IPS_CUR_INTENT = 6146; private const int WIA_IPS_XRES = 6147; private const int WIA_IPS_YRES = 6148; private const int WIA_INTENT_NONE = 0x00000000; private const int WIA_INTENT_IMAGE_TYPE_COLOR = 0x00000001; private const int WIA_INTENT_IMAGE_TYPE_GRAYSCALE = 0x00000002; private const int WIA_INTENT_IMAGE_TYPE_TEXT = 0x00000004; private const int WIA_INTENT_IMAGE_TYPE_MASK = 0x0000000F; private const int WIA_INTENT_MINIMIZE_SIZE = 0x00010000; private const int WIA_INTENT_MAXIMIZE_QUALITY = 0x00020000; private const int WIA_INTENT_BEST_PREVIEW = 0x00040000; private const int WIA_INTENT_SIZE_MASK = 0x000F0000; private const int FEED_READY = 0x01; private const string wiaFormatPNG = "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"; private void TestScan() { DeviceManager manager = new DeviceManager(); object index = 1; DeviceInfo info = manager.DeviceInfos.get_Item(ref index); Device dvc = info.Connect(); object res = 150; object intent = WIA_INTENT_IMAGE_TYPE_COLOR; object statusProp = WIA_DPS_DOCUMENT_HANDLING_STATUS_STR; int documentStatus = 0; object pgs = 0; object handler = WIA_DPS_DOCUMENT_HANDLING_SELECT_FEEDER; foreach (Property p in dvc.Properties) { switch (p.PropertyID) { case WIA_PROPERTIES_WIA_DPS_DOCUMENT_HANDLING_SELECT: p.set_Value(ref handler); break; case WIA_IPS_XRES: case WIA_IPS_YRES: p.set_Value(ref res); break; case WIA_IPS_CUR_INTENT: p.set_Value(ref intent); break; case WIA_PROPERTIES_WIA_DPS_DOCUMENT_HANDLING_STATUS: documentStatus = (int)p.get_Value(); break; case WIA_IPS_PAGES: p.set_Value(ref pgs); break; } } foreach (Item itm in dvc.Items) { while ((documentStatus & FEED_READY) == FEED_READY) { itm.Transfer(wiaFormatPNG); documentStatus = (int)dvc.Properties.get_Item(ref statusProp).get_Value(); } } } I got this code idea from http://www.xtremevbtalk.com/showthread.php?t=288758. However, the DOCUMENT HANDLING STATUS always stays 5 even when all the pages are scanned through. This eventually ends in a com exception being thrown when all the pages have been scanned. I could just throw a try catch around the whole thing but that doesn't seem right to me. I don't like it. Does anyone have any suggestions for me? This code needs to work regardless of what scanner is being used. Is WIA the wrong choice here? Should I go right to TWAIN code? Thanks in advance for any help anyone can give me. Previous Posts In This Thread: On 01 March 2008 15:44 Tom G. wrote: How to write C# program using WIA Automation 2.0 to support Multi Feed Scanner I am working on a project right now that needs to be able to scan in multiple pages using a scanner's multi feed feature. The scanner that I am using to test is Fujitsu fi-5120C. I am coding this project in C# and am trying to use WIA Automation 2.0 Library. I am open to alternative technologies if someone has any suggestions. My test case is that I have three sheets of paper in the document feeder and I want my code to scan in all three pages at once. All the pages get scanned correctly when I call the following code: private void CallScanWizard() { WIA.CommonDialog dlg = new WIA.CommonDialog(); Device dvc = dlg.ShowSelectDevice(WiaDeviceType.ScannerDeviceType,true,false); if (dvc != null) { dlg.ShowAcquisitionWizard(dvc); } } This tells me that it is possible in WIA. However, this can't be the solution for me. I don't want the user to have to pick a file path for the images to be saved to. I want to work with them in memory only. So I tried the following code: private const int WIA_DPS_DOCUMENT_HANDLING_SELECT_FEEDER = 1; private const int WIA_DPS_DOCUMENT_HANDLING_SELECT_FLATBED = 2; private const int WIA_IPS_PAGES = 3096; private const int WIA_DPS_DOCUMENT_HANDLING_STATUS_FEED_READY = 1; private const int WIA_PROPERTIES_WIA_RESERVED_FOR_NEW_PROPS = 1024; private const int WIA_PROPERTIES_WIA_DIP_FIRST = 2; private const int WIA_PROPERTIES_WIA_DPA_FIRST = WIA_PROPERTIES_WIA_DIP_FIRST + WIA_PROPERTIES_WIA_RESERVED_FOR_NEW_PROPS; private const int WIA_PROPERTIES_WIA_DPC_FIRST = WIA_PROPERTIES_WIA_DPA_FIRST + WIA_PROPERTIES_WIA_RESERVED_FOR_NEW_PROPS; private const int WIA_PROPERTIES_WIA_DPS_FIRST = WIA_PROPERTIES_WIA_DPC_FIRST + WIA_PROPERTIES_WIA_RESERVED_FOR_NEW_PROPS; private const int WIA_PROPERTIES_WIA_DPS_DOCUMENT_HANDLING_STATUS = WIA_PROPERTIES_WIA_DPS_FIRST + 13; private const int WIA_PROPERTIES_WIA_DPS_DOCUMENT_HANDLING_SELECT = WIA_PROPERTIES_WIA_DPS_FIRST + 14; private const string WIA_DPS_DOCUMENT_HANDLING_STATUS_STR = "Document Handling Status"; private const double WIA_ERRORS_BASE_VAL_WIA_ERROR = 2149646336; private const double WIA_ERRORS_WIA_ERROR_PAPER_EMPTY = WIA_ERRORS_BASE_VAL_WIA_ERROR + 3; private const int WIA_IPS_CUR_INTENT = 6146; private const int WIA_IPS_XRES = 6147; private const int WIA_IPS_YRES = 6148; private const int WIA_INTENT_NONE = 0x00000000; private const int WIA_INTENT_IMAGE_TYPE_COLOR = 0x00000001; private const int WIA_INTENT_IMAGE_TYPE_GRAYSCALE = 0x00000002; private const int WIA_INTENT_IMAGE_TYPE_TEXT = 0x00000004; private const int WIA_INTENT_IMAGE_TYPE_MASK = 0x0000000F; private const int WIA_INTENT_MINIMIZE_SIZE = 0x00010000; private const int WIA_INTENT_MAXIMIZE_QUALITY = 0x00020000; private const int WIA_INTENT_BEST_PREVIEW = 0x00040000; private const int WIA_INTENT_SIZE_MASK = 0x000F0000; private const int FEED_READY = 0x01; private const string wiaFormatPNG = "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"; private void TestScan() { DeviceManager manager = new DeviceManager(); object index = 1; DeviceInfo info = manager.DeviceInfos.get_Item(ref index); Device dvc = info.Connect(); object res = 150; object intent = WIA_INTENT_IMAGE_TYPE_COLOR; object statusProp = WIA_DPS_DOCUMENT_HANDLING_STATUS_STR; int documentStatus = 0; object pgs = 0; object handler = WIA_DPS_DOCUMENT_HANDLING_SELECT_FEEDER; foreach (Property p in dvc.Properties) { switch (p.PropertyID) { case WIA_PROPERTIES_WIA_DPS_DOCUMENT_HANDLING_SELECT: p.set_Value(ref handler); break; case WIA_IPS_XRES: case WIA_IPS_YRES: p.set_Value(ref res); break; case WIA_IPS_CUR_INTENT: p.set_Value(ref intent); break; case WIA_PROPERTIES_WIA_DPS_DOCUMENT_HANDLING_STATUS: documentStatus = (int)p.get_Value(); break; case WIA_IPS_PAGES: p.set_Value(ref pgs); break; } } foreach (Item itm in dvc.Items) { while ((documentStatus & FEED_READY) == FEED_READY) { itm.Transfer(wiaFormatPNG); documentStatus = (int)dvc.Properties.get_Item(ref statusProp).get_Value(); } } } I got this code idea from http://www.xtremevbtalk.com/showthread.php?t=288758. However, the DOCUMENT HANDLING STATUS always stays 5 even when all the pages are scanned through. This eventually ends in a com exception being thrown when all the pages have been scanned. I could just throw a try catch around the whole thing but that doesn't seem right to me. I don't like it. Does anyone have any suggestions for me? This code needs to work regardless of what scanner is being used. Is WIA the wrong choice here? Should I go right to TWAIN code? Thanks in advance for any help anyone can give me. EggHeadCafe - Software Developer Portal of Choice Excel Macros - Create And Run in C# at Runtime http://www.eggheadcafe.com/tutorials/aspnet/fc339e7c-ce0f-4a1e-96fc-5ef649a032b9/excel-macros--create-and.aspx
|
Pages: 1 Prev: Linq Many to Many relationship and XML Next: Excel Pivot Items Using C# - Unable to Access |