2010-10-27 51 views
3

我正在用C#開發應用程序以使用WIA 2.0庫。目前我可以使用大部分功能,例如ADF(自動文檔進紙器),濾鏡等等。WIA 2.0雙面打印屬性

現在,我需要使用我的掃描儀(fujitsu)的雙面打印器。

我試圖將WIA_DPS_DOCUMENT_HANDLING_SELECT掃描儀屬性設置爲DUPLEX值。請參見下面的代碼:

try 
     { 
      bool hasMorePages = false; 
      //determine if there are any more pages waiting 
      Property documentHandlingSelect = null; 
      Property documentHandlingStatus = null; 
      foreach (Property prop in WiaDev.Properties) 
      { 
       if (prop.PropertyID == WIA_PROPERTIES.WIA_DPS_DOCUMENT_HANDLING_SELECT) 
        documentHandlingSelect = prop; 
       if (prop.PropertyID == WIA_PROPERTIES.WIA_DPS_DOCUMENT_HANDLING_STATUS) 
        documentHandlingStatus = prop; 
      } 

      object obj = new object(); 
      obj = (WIA_DPS_DOCUMENT_HANDLING_SELECT.DUPLEX); 
      documentHandlingSelect.set_Value(ref obj); 

      if (documentHandlingSelect != null) //may not exist on flatbed scanner but required for feeder 
      { 
       //check for document feeder 
       if ((Convert.ToUInt32(documentHandlingSelect.get_Value()) & WIA_DPS_DOCUMENT_HANDLING_SELECT.FEEDER) != 0) 
       { 
        hasMorePages = ((Convert.ToUInt32(documentHandlingStatus.get_Value()) & WIA_DPS_DOCUMENT_HANDLING_STATUS.FEED_READY) != 0); 
        if (hasMorePages) 
        { 
         // set the property to use FEEDER and DUPLEX (this result in the value of 5 in the property) 
         object obj = new object(); 
         obj = (WIA_DPS_DOCUMENT_HANDLING_SELECT.FEEDER | WIA_DPS_DOCUMENT_HANDLING_SELECT.DUPLEX); 
         documentHandlingSelect.set_Value(ref obj); 
        } 
       } 
      } 
      return hasMorePages; 

此代碼編譯好了,但我沒能得到兩個圖像,當我執行這條線。它僅檢索前:

imgFile = (ImageFile)wiaCommonDialog.ShowTransfer(item, format.Guid.ToString("B")/* wiaFormatJPEG*/, false); 

我讀到許多主題,該文檔還,有可能讓孩子的物體形成掃描儀上的項目,但只有一個在此集合中的項目。

請有人幫助我!

感謝

回答

3

我讀過一個你傳遞第一圖像的第二圖像可使用相同的參考,所以你只需要調用的第一行代碼的兩倍。這似乎有點奇怪,但適用於我的一臺雙面掃描儀。

例如

imgFile = (ImageFile)wiaCommonDialog.ShowTransfer(item, format.Guid.ToString("B")/* wiaFormatJPEG*/, false); 
imgFile2 = (ImageFile)wiaCommonDialog.ShowTransfer(item, format.Guid.ToString("B")/* wiaFormatJPEG*/, false); 

這可能適合你。我在雙面掃描方面也遇到了麻煩,但是我設法使用我的一臺掃描儀。