question

Francesco-6151 avatar image
0 Votes"
Francesco-6151 asked DanielZhang-MSFT edited

Use a scanner with ADF in c#

I would like to use a scanner by loading documents from the ADF, but I have not found anything to help me set the source as ADF and not flat. I have made a lot of attempts, I think it is necessary to set the Properties, I tried to do it with this code, but it does not read any of the settings made.

             WIA.CommonDialog _dialog = new CommonDialog();
             WIA.Device _scanner = _dialog.ShowSelectDevice(WIA.WiaDeviceType.ScannerDeviceType, false, false);
    
             foreach (Property item in _scanner.Items[1].Properties)
             {
                 switch (item.PropertyID)
                 {
                     case 6146: //4 is Black-white,gray is 2, color 1
                         SetProperty(item, 2);
                         break;
                     case 6147: //dots per inch/horizontal 
                         SetProperty(item, 100);
                         break;
                     case 6148: //dots per inch/vertical 
                         SetProperty(item, 100);
                         break;
                     case 6149: //x point where to start scan 
                         SetProperty(item, 0);
                         break;
                     case 6150: //y-point where to start scan 
                         SetProperty(item, 0);
                         break;
                     case 6151: //horizontal exent 
                         SetProperty(item, (int)(8.5 * 100));
                         break;
                     case 6152: //vertical extent 
                         SetProperty(item, 11 * 100);
                         break;
                 }
             }
    
             CommonDialog oDialog = new CommonDialog();
             oDialog.ShowAcquisitionWizard(_scanner);
    

     private void SetProperty(Property property, int value)
     {
         IProperty x = (IProperty)property;
         Object val = value;
         x.set_Value(ref val);
     }
dotnet-csharpwindows-forms
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Francesco-6151,
Here is a code example and contains a Winforms test app.
Hope it is helpful to you.
Best Regards,
Daniel Zhang


0 Votes 0 ·

0 Answers