2010-02-11 29 views
8

Tôi đang sử dụng WIA để lấy hình ảnh từ máy quét có C#. Tôi có thể quét các giấy tờ, nhưng tôi không thể thiết lập kích thước trang một cách chính xác, nó luôn luôn mặc định là A4 và tôi cần phải sử dụng Letter hoặc Legal đôi khi.Đặt kích thước trang bằng WIA (với máy quét)

Tôi đã thử với thuộc tính WIA_DPS_PAGE_SIZE, nhưng khi tôi cố đặt giá trị, tôi luôn gặp lỗi, rằng giá trị nằm ngoài khoảng thời gian (đã thử nhiều giá trị có thể).

Tôi không thể sử dụng WIA_DPS_PAGE_SIZE = WIA_PAGE_AUTO (đối với kích thước trang tự động), nhưng tôi không thể tìm thấy bất kỳ nội dung nào trên web liên quan đến điều này.

Có ai biết giải pháp không? cảm ơn!

Trả lời

10

Tôi biết điều này có thể là quá muộn để thực sự giúp bạn với điều đó, nhưng nó có thể trở nên thuận tiện để tham khảo trong tương lai. Để thay đổi mục quét đặc tính sử dụng mã ví dụ:

WIA.CommonDialog wiaDlg; 
WIA.Device wiaDevice; 
WIA.DeviceManager wiaManager = new DeviceManager(); 

wiaDlg = new WIA.CommonDialog(); 
wiaDevice = wiaDlg.ShowSelectDevice(WiaDeviceType.ScannerDeviceType, false, false); 

foreach (WIA.Item item in wiaDevice.Items) 
{ 
    StringBuilder propsbuilder = new StringBuilder(); 

    foreach (WIA.Property itemProperty in item.Properties) 
    { 
     IProperty tempProperty; 
     Object tempNewProperty; 

     if (itemProperty.Name.Equals("Horizontal Resolution")) 
     { 
      tempNewProperty = 75; 
      ((IProperty)itemProperty).set_Value(ref tempNewProperty); 
     } 
     else if (itemProperty.Name.Equals("Vertical Resolution")) 
     { 
      tempNewProperty = 75; 
      ((IProperty)itemProperty).set_Value(ref tempNewProperty); 
     } 
     else if (itemProperty.Name.Equals("Horizontal Extent")) 
     { 
      tempNewProperty = 619; 
      ((IProperty)itemProperty).set_Value(ref tempNewProperty); 
     } 
     else if (itemProperty.Name.Equals("Vertical Extent")) 
     { 
      tempNewProperty = 876; 
      ((IProperty)itemProperty).set_Value(ref tempNewProperty); 
     } 
    } 

    image = (ImageFile)item.Transfer(WIA.FormatID.wiaFormatPNG); 
} 

Điều này có nghĩa rằng tài liệu được quét sẽ được kích thước A4 với kích thước 619 x 876.

Các vấn đề liên quan