// Set up
using var scanningContext = new ScanningContext(new GdiImageContext());
var controller = new ScanController(scanningContext);
// Query for available scanning devices
var devices = await controller.GetDeviceList();
// Set scanning options
var options = new ScanOptions
{
Device = devices.First(),
PaperSource = PaperSource.Feeder,
PageSize = PageSize.A4,
Dpi = 300
};
// Scan and save images
int i = 1;
await foreach (var image in controller.Scan(options))
{
image.Save($"page{i++}.jpg");
}
// Scan and save PDF
var images = await controller.Scan(options).ToListAsync();
var pdfExporter = new PdfExporter(scanningContext);
await pdfExporter.Export("doc.pdf", images);
NAPS2 SDK is a free and open source scanning library for C#/.NET.
Scan with devices from Canon, Brother, HP, Epson, Fujitsu, and more. Then save to PDF, TIFF, JPEG, or PNG.
Features: