Saraff.TwainX 1.0.35

dotnet add package Saraff.TwainX --version 1.0.35
                    
NuGet\Install-Package Saraff.TwainX -Version 1.0.35
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Saraff.TwainX" Version="1.0.35" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Saraff.TwainX" Version="1.0.35" />
                    
Directory.Packages.props
<PackageReference Include="Saraff.TwainX" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Saraff.TwainX --version 1.0.35
                    
#r "nuget: Saraff.TwainX, 1.0.35"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Saraff.TwainX@1.0.35
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Saraff.TwainX&version=1.0.35
                    
Install as a Cake Addin
#tool nuget:?package=Saraff.TwainX&version=1.0.35
                    
Install as a Cake Tool

Saraff.TwainX (.NET Standard 2.0)

Saraff.TwainX is the skillful scanning component which allows you to control work 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.

license: LGPL 3.0 or later NuGet version NuGet downloads

Products

This repository contains two separate products. They are not interchangeable: the package id, assembly name, namespace and public API are different.

Product Branch Package Target Main class Image transfer
Saraff.Twain master Saraff.Twain net462, net8.0-windows Saraff.Twain.Twain32 System.Drawing.Image / WPF ImageSource
Saraff.TwainX twainx Saraff.TwainX netstandard2.0 Saraff.TwainX.TwainX Stream via IImageFactory<T>

Saraff.TwainX (this branch)

Cross-platform implementation for TWAIN 2.x (DS2) data sources. It does not depend on WinForms or WPF, uses IntPtr for the parent window and transfers images as streams.

  • ShowUI defaults to false.
  • Parent is IntPtr and is applied to DG_CONTROL / DAT_USERINTERFACE / MSG_ENABLEDS.
  • Acquire() requires a TWAIN 2.x/DS2 data source and a TWAIN 2.x DSM.
  • DsmPath can be used to point to a non-default libtwaindsm / TWAINDSM library.

Asynchronous acquisition

AcquireAsync uses a dedicated session thread. On Windows the thread is STA and pumps Win32 messages; on other platforms it is a serialized background thread without a Win32 message pump.

using var session = new TwainXAcquisitionSession(new TwainXAcquireOptions {
    ShowUI = true,
    DisableAfterAcquire = true,
    MaxImages = 1
});
using var result = await session.AcquireAsync();
foreach (var stream in result.Streams) {
    // stream is a result-owned MemoryStream copied from the transfer
}

The overload with a callback runs it on the session thread after the data source is opened and before it is enabled. This is the point where capabilities, image layout and other data source settings can be applied:

using var result = await session.AcquireAsync(twain => {
    twain.Capabilities.XResolution.Set(300);
    twain.Capabilities.YResolution.Set(300);
    twain.Capabilities.PixelType.Set(TwPixelType.Gray);
});

The synchronous Acquire() API remains available and unchanged.

Install-Package Saraff.TwainX

Saraff.Twain

Windows implementation. Supports TWAIN 1.x and TWAIN 2.x data sources, WinForms/WPF parents, System.Drawing.Image results and the Twain32 component.

Install-Package Saraff.Twain

Documented differences

Do not assume that Twain32 and TwainX have identical defaults or signatures:

  • ShowUI defaults to true in Twain32 and to false in TwainX.
  • Parent is IWin32Window in Twain32 and IntPtr in TwainX.
  • Twain32 exposes GetImage, ImageCount, Image, ImageSource, IsTwain2Enable and IsTwain2Supported; TwainX does not.
  • TwainX requires a TWAIN 2.x/DS2 source and a TWAIN 2.x DSM.
  • TwainX.EndXferEventArgs.Stream exposes the underlying stream; it is rewound to the beginning and remains owned by the event args.

Build

dotnet build Saraff.TwainX.csproj -c Release
dotnet test tests/Saraff.TwainX.Tests/Saraff.TwainX.Tests.csproj -c Release

Also, you can see:

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

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.0.35 0 12/1/2026
1.0.34 71 11/26/2026