Simple Java library for document scanning on Windows via TWAIN (64-bit) and WIA (Windows Image Acquisition).
| Requirement | Version |
|---|---|
| Java | 25+ |
| Maven | 3.9+ |
| OS | Windows (64-bit for TWAIN, any version for WIA) |
Add the dependency to your pom.xml:
<dependency>
<groupId>com.sijareca</groupId>
<artifactId>scan4java</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>Until the artifact is published to Maven Central, clone the repository and run
mvn installto install it in your local repository.
List<Scanner> scanners = ScanManager.instance().getScanners();
scanners.forEach(s -> System.out.println(s.getName() + " [" + s.getProtocol() + "]"));Scanner scanner = ScanManager.instance().getScanners().get(0);
List<BufferedImage> pages = scanner.scan();ScanConfig config = ScanConfig.defaults()
.dpi(300)
.color(ColorMode.COLOR)
.adf(true)
.duplex(true);
List<BufferedImage> pages = scanner.scan(config);// Only TWAIN scanners
List<Scanner> twainScanners = ScanManager.instance().getScanners(Protocol.TWAIN);
// Only WIA scanners
List<Scanner> wiaScanners = ScanManager.instance().getScanners(Protocol.WIA);- Integration Guide (integracion.md): Detailed guide on how to use scan4java in your Java application.
- Technical Design (scan4java.md): Internal design decisions and implementation details.
Singleton entry point. Queries both TWAIN and WIA providers and deduplicates results — when the same physical device appears in both protocols, TWAIN takes precedence.
| Method | Description |
|---|---|
ScanManager.instance() |
Returns the singleton instance |
getScanners() |
Returns all available scanners |
getScanners(Protocol) |
Returns scanners filtered by protocol |
| Method | Description |
|---|---|
getId() |
Protocol-specific device identifier |
getName() |
Human-readable device name |
getProtocol() |
Protocol.TWAIN or Protocol.WIA |
scan() |
Scan with default settings |
scan(ScanConfig) |
Scan with custom configuration |
Fluent builder. Defaults: 200 DPI, grayscale, ADF off, duplex off.
| Method | Default |
|---|---|
dpi(int) |
200 |
color(ColorMode) |
ColorMode.GRAYSCALE |
adf(boolean) |
false |
duplex(boolean) |
false |
BW · GRAYSCALE · COLOR
TWAIN
- Requires Windows 64-bit and
TWAINDSM.DLLinstalled. - Supports multi-page ADF scanning (returns one
BufferedImageper page). - Uses the standard TWAIN state machine with a Windows message loop.
WIA
- Works on any Windows version via COM.
- Transfers each page to a temporary BMP file and reads it with
ImageIO.
mvn clean package # Compile and build JAR
mvn test # Run tests
mvn verify # Compile + test + package