NAPS2.Wia is a standalone component that acts as a low-level wrapper around Windows Image Acquisition (WIA).
Compared to the COM-based wiaaut.dll, you get:
If you're looking for a higher-level and easier-to-use scanning interface, check out NAPS2.Sdk.
using var deviceManager = new WiaDeviceManager();
// Prompt the user to select a scanner
using var device = deviceManager.PromptForDevice();
// Select either "Flatbed" or "Feeder"
using var item = device.FindSubItem("Feeder");
// Scan all pages in the feeder at once
item.SetProperty(WiaPropertyId.IPS_PAGES,
WiaPropertyValue.ALL_PAGES);
// Enable duplex scanning
item.SetProperty(WiaPropertyId.IPS_DOCUMENT_HANDLING_SELECT,
WiaPropertyValue.DUPLEX);
// Set up the scan
using var transfer = item.StartTransfer();
transfer.PageScanned += (sender, args) =>
{
using (args.Stream)
{
var bitmap = new Bitmap(args.Stream);
// Do something with the image
}
};
// Do the actual scan
transfer.Download();
Unlike most of NAPS2.Sdk which is licensed under the LGPL, NAPS2.Wia uses the more permissive MIT license.