Saraff.Twain.DS
Saraff.Twain.DS is the skillful class library which allows you to design drivers (a Data Source) of flatbed scanner, web and digital camera and any other TWAIN device from .NET environment. You can use this library in your programs written in any programming languages compatible with .NET technology.
Features:
- TWAIN specification 1.x / 2.x compatible
- Programming environments: .NET Framework 4.8 and .NET 8 (Windows)
- Full support for x86 and x64 platforms
- This is a fully-managed .NET library
- Supports Native, Buffered Memory, Disk File and Memory File image transfer mode
- Localization: English (neutral) and Russian (
rusatellite resources) - Dependency: Saraff.IoC 2.0.0
Current release: 1.2.0
- NuGet package
- GitHub Release
- The package contains both
net48andnet8.0-windows7.0assemblies; NuGet selects the appropriate target framework.
What’s new in 1.2.0
- Correct handling of
ICAP_XFERCOUNT = -1(an indeterminate number of pending transfers): the Source stays in State 6,DAT_PENDINGXFERSreports0xFFFF, andMSG_ENDXFERdoes not decrement the count. - New
XferEnvironment.PendingXfersIndeterminateproperty andDataSource.EndOfXfers()method. ICAP_XFERCOUNTnow defaults to1;0and values below-1are rejected withTWCC_BADVALUE.
Supported frameworks:
- .NET Framework 4.8 (
net48) - .NET 8 (
net8.0-windows)
System requirements:
- .NET Framework 4.8 (for the
net48build) or the .NET 8 Desktop Runtime (for thenet8.0-windowsbuild) - Windows 10 / 11, 32-bit / 64-bit (the
net48build may also run on Windows 7 SP1+ with .NET Framework 4.8; not covered by CI) - To build from source: Visual Studio 2022 (17.x, MSVC v143) and the .NET 8 SDK
Tested with:
- Microsoft Visual Studio 2022
- Windows 10 / 11 x64 (x86 builds are also produced)
Build, CI and publishing:
Saraff.Twain.DS.slnbuilds the managednet48/net8libraries and the nativex86/x64.dsentry points.- GitHub Actions: CI (build + tests) and Publish (NuGet.org via Trusted Publishing + GitHub Release).
- Release assets: a combined NuGet package and
net48/net8x86/x64.dsarchives.
NuGet package
Documentation
Samples:
- Saraff Screen DS (UPDATED. 22.12.2019) (TWAIN Certified Driver)
- Saraff DirectX DS (UPDATED. 07.03.2020) (TWAIN Certified Driver)
The samples were built against earlier versions of the library; update the
Saraff.Twain.DSpackage reference to 1.2.0.

Figure 1 - Saraff.Twain.DS.Screen on Windows 10 x64
TWAIN Specification
Saraff.Twain.DS implements TWAIN 2.3 Specification. Explanation of specification is not the purpose of this project. Here will be explained features of the implementation of TWAIN specification.
If you notice an error, please let me know about it.