NAPS2.Sdk
1.1.2
Prefix Reserved
dotnet add package NAPS2.Sdk --version 1.1.2
NuGet\Install-Package NAPS2.Sdk -Version 1.1.2
<PackageReference Include="NAPS2.Sdk" Version="1.1.2" />
paket add NAPS2.Sdk --version 1.1.2
#r "nuget: NAPS2.Sdk, 1.1.2"
// Install NAPS2.Sdk as a Cake Addin #addin nuget:?package=NAPS2.Sdk&version=1.1.2 // Install NAPS2.Sdk as a Cake Tool #tool nuget:?package=NAPS2.Sdk&version=1.1.2
NAPS2.Sdk
NAPS2.Sdk is a fully-featured scanning library, supporting WIA, TWAIN, SANE, and ESCL scanners on Windows, Mac, and Linux.
Packages
NAPS2.Sdk is modular, and depending on your needs you may have to reference a different set of packages.
Required Packages
- NAPS2.Sdk
- Contains core scanning functionality for all platforms.
- Exactly one of:
- NAPS2.Images.Gdi
- For working with
System.Drawing.Bitmap
images. (Windows Forms)
- For working with
- NAPS2.Images.Wpf
- For working with
System.Windows.Media.Imaging
images. (WPF)
- For working with
- NAPS2.Images.Gtk
- For working with
Gdk.Pixbuf
images. (Linux)
- For working with
- NAPS2.Images.Mac
- For working with
AppKit.NSImage
images. (Mac)
- For working with
- NAPS2.Images.ImageSharp
- For working with
ImageSharp
images.
- For working with
- NAPS2.Images.Gdi
Optional Packages
- NAPS2.Sdk.Worker.Win32
- For scanning with TWAIN on Windows.
- NAPS2.Pdfium.Binaries
- For importing PDFs.
- NAPS2.Sane.Binaries
- For using SANE drivers on Mac. (Linux has them pre-installed, and Windows isn't supported.)
- NAPS2.Tesseract.Binaries
- For running OCR. (You can also use a separate Tesseract installation if you like.)
- NAPS2.Escl.Server
- For sharing scanners across the local network.
Usage
// 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);
More samples:
- "Hello World" scanning
- Scan and save to PDF/images
- Scan with TWAIN drivers
- Scan to System.Drawing.Bitmap
- Import and export PDFs
- Export PDFs with OCR
- Store image data on the filesystem
- Share scanners on the local network
Also see:
Web Scanning with JS/TS
NAPS2's scanner-sharing server uses ESCL, which is a standard HTTP protocol and can be used from a web browser with JavaScript or TypeScript.
See the naps2-webscan project for example code to scan from a browser.
Drivers
Windows | Mac | Linux | |
---|---|---|---|
WIA | X | ||
TWAIN | X | * | |
Apple | X | ||
SANE | X | X | |
ESCL | X | X | X |
WIA (Windows Image Acquisition) is a Microsoft technology for scanners (and cameras). Many scanners provide WIA drivers for Windows.
TWAIN is a cross-platform standard for image acquisition. Many scanners provide TWAIN drivers for Windows and/or Mac.
Apple's ImageCaptureCore provides access to TWAIN and ESCL scanners on Mac devices.
SANE is an open-source API and set of backends for various scanners. Primarily for Linux, supported devices use backends made by open-source contributors or the manufacturer themselves.
ESCL, also known as Apple AirScan, is a standard protocol for scanning over a network. Many modern scanners support ESCL, and as it's a network protocol, specific drivers aren't required. ESCL can also be used over a USB connection in some cases.
Choosing a Driver
Each platform has a default driver (WIA on Windows, Apple on Mac, and SANE on Linux). To use another driver, you only need to specify it when querying for devices:
var devices = await controller.GetDeviceList(Driver.Twain);
Worker Processes
Using the TWAIN driver on Windows usually requires the calling process to be 32-bit. If you want to use TWAIN from a 64-bit process, NAPS2 provides a 32-bit worker process:
// Reference the NAPS2.Sdk.Worker.Win32 package and call this method
scanningContext.SetUpWin32Worker();
Contributing
Looking to contribute to NAPS2 or NAPS2.Sdk? Have a look at the wiki.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-macos10.15 is compatible. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETFramework 4.6.2
- GrpcDotNetNamedPipes (>= 3.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.1)
- NAPS2.Escl (>= 1.1.2)
- NAPS2.Images (>= 1.1.2)
- NAPS2.Internals (>= 1.1.2)
- NAPS2.NTwain (>= 1.0.0)
- NAPS2.PdfSharp (>= 1.0.1)
- NAPS2.Wia (>= 2.0.3)
- SharpZipLib (>= 1.4.2)
- SixLabors.Fonts (>= 1.0.1)
- System.Collections.Immutable (>= 8.0.0)
- System.Resources.Extensions (>= 8.0.0)
- System.Threading.Tasks.Dataflow (>= 8.0.1)
- ZXing.Net (>= 0.16.9)
-
net6.0
- GrpcDotNetNamedPipes (>= 3.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.1)
- NAPS2.Escl (>= 1.1.2)
- NAPS2.Images (>= 1.1.2)
- NAPS2.Internals (>= 1.1.2)
- NAPS2.NTwain (>= 1.0.0)
- NAPS2.PdfSharp (>= 1.0.1)
- NAPS2.Wia (>= 2.0.3)
- SharpZipLib (>= 1.4.2)
- SixLabors.Fonts (>= 1.0.1)
- System.Collections.Immutable (>= 8.0.0)
- System.Resources.Extensions (>= 8.0.0)
- System.Threading.Tasks.Dataflow (>= 8.0.1)
- ZXing.Net (>= 0.16.9)
-
net8.0-macos10.15
- GrpcDotNetNamedPipes (>= 3.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.1)
- NAPS2.Escl (>= 1.1.2)
- NAPS2.Images (>= 1.1.2)
- NAPS2.Images.Mac (>= 1.1.2)
- NAPS2.Internals (>= 1.1.2)
- NAPS2.PdfSharp (>= 1.0.1)
- SharpZipLib (>= 1.4.2)
- SixLabors.Fonts (>= 1.0.1)
- System.Collections.Immutable (>= 8.0.0)
- System.Resources.Extensions (>= 8.0.0)
- System.Threading.Tasks.Dataflow (>= 8.0.1)
- ZXing.Net (>= 0.16.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.1.2 | 252 | 8/17/2024 |
1.1.1 | 72 | 8/17/2024 |
1.1.0 | 115 | 8/11/2024 |
1.0.2 | 230 | 7/6/2024 |
1.0.1 | 5,360 | 4/14/2024 |
1.0.0 | 267 | 4/9/2024 |
0.6.0 | 1,127 | 3/11/2024 |
0.5.0 | 157 | 3/3/2024 |
0.4.0 | 108 | 3/1/2024 |
0.3.0 | 370 | 2/7/2024 |
0.2.3 | 232 | 1/15/2024 |
0.2.2 | 188 | 12/30/2023 |
0.2.1 | 119 | 12/30/2023 |
0.2.0 | 124 | 12/30/2023 |
0.1.0-alpha08 | 155 | 12/17/2023 |
0.1.0-alpha07 | 101 | 12/14/2023 |
0.1.0-alpha06 | 96 | 12/13/2023 |
0.1.0-alpha05 | 291 | 10/11/2023 |
0.1.0-alpha04 | 147 | 9/5/2023 |
0.1.0-alpha03 | 176 | 8/30/2023 |
0.1.0-alpha02 | 106 | 8/30/2023 |
0.1.0-alpha01 | 171 | 8/26/2023 |