Twain.Wia.Sane.Scanner 1.1.0

dotnet add package Twain.Wia.Sane.Scanner --version 1.1.0
NuGet\Install-Package Twain.Wia.Sane.Scanner -Version 1.1.0
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="Twain.Wia.Sane.Scanner" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Twain.Wia.Sane.Scanner --version 1.1.0
#r "nuget: Twain.Wia.Sane.Scanner, 1.1.0"
#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.
// Install Twain.Wia.Sane.Scanner as a Cake Addin
#addin nuget:?package=Twain.Wia.Sane.Scanner&version=1.1.0

// Install Twain.Wia.Sane.Scanner as a Cake Tool
#tool nuget:?package=Twain.Wia.Sane.Scanner&version=1.1.0

.NET Document Scanner for TWAIN, WIA, SANE, ICA, and eSCL

The package provides methods for calling Dynamsoft Service REST APIs. This allows developers to build .NET applications for digitizing documents from TWAIN (32-bit/64-bit), WIA, SANE, ICA and eSCL scanners.


  1. Install Dynamsoft Service.

  2. Request a free trial license.

Dynamsoft Service REST API

By default, the REST API's host address is set to

Method Endpoint Description Parameters Response
GET /DWTAPI/Scanners Get a list of scanners None 200 OK with scanner list
POST /DWTAPI/ScanJobs Creates a scan job license, device, config 201 Created with job ID
GET /DWTAPI/ScanJobs/:id/NextDocument Retrieves a document image id: Job ID 200 OK with image stream
DELETE /DWTAPI/ScanJobs/:id Deletes a scan job id: Job ID 200 OK

You can navigate to to access the service. To make it accessible from desktop, mobile, and web applications on the same network, you can change the host address to a LAN IP address. For example, you might use


The scanner parameter configuration is based on Dynamsoft Web TWAIN documentation.

Quick Start

Replace the license key in the code below with a valid one and run the code.

using System;
using System.Collections.Generic;
using Twain.Wia.Sane.Scanner;

public class Program
    private static string licenseKey = "LICENSE-KEY";
    private static ScannerController scannerController = new ScannerController();
    private static List<Dictionary<string, object>> devices = new List<Dictionary<string, object>>();
    private static string host = "";
    private static string questions = @"
Please select an operation:
1. Get scanners
2. Acquire documents by scanner index
3. Quit

    public static async Task Main()
        await AskQuestion();

    private static async Task<int> AskQuestion()
        while (true)
            string? answer = Console.ReadLine();

            if (string.IsNullOrEmpty(answer))

            if (answer == "3")
            else if (answer == "1")
                var scanners = await scannerController.GetDevices(host, ScannerType.TWAINSCANNER | ScannerType.TWAINX64SCANNER);
                for (int i = 0; i < scanners.Count; i++)
                    var scanner = scanners[i];
                    Console.WriteLine($"\nIndex: {i}, Name: {scanner["name"]}");
            else if (answer == "2")
                if (devices.Count == 0)
                    Console.WriteLine("Please get scanners first!\n");

                Console.Write($"\nSelect an index (<= {devices.Count - 1}): ");
                int index;
                if (!int.TryParse(Console.ReadLine(), out index))
                    Console.WriteLine("Invalid input. Please enter a number.");

                if (index < 0 || index >= devices.Count)
                    Console.WriteLine("It is out of range.");

                var parameters = new Dictionary<string, object>
                    {"license", licenseKey},
                    {"device", devices[index]["device"]}

                parameters["config"] = new Dictionary<string, object>
                    {"IfShowUI", false},
                    {"PixelType", 2},
                    {"Resolution", 200},
                    {"IfFeederEnabled", false},
                    {"IfDuplexEnabled", false}

                string jobId = await scannerController.ScanDocument(host, parameters);

                if (!string.IsNullOrEmpty(jobId))
                    var images = await scannerController.GetImageFiles(host, jobId, "./");
                    for (int i = 0; i < images.Count; i++)
                        Console.WriteLine($"Image {i}: {images[i]}");

                    scannerController.DeleteJob(host, jobId);
        return 0;



  • public async Task<List<Dictionary<string, object>>> GetDevices(string host, int? scannerType = null): Get a list of available devices.
  • public async Task<string> ScanDocument(string host, Dictionary<string, object> parameters): Scan a document.
  • public async void DeleteJob(string host, string jobId): Delete a job.
  • public async Task<string> GetImageFile(string host, string jobId, string directory): Get an image file.
  • public async Task<List<string>> GetImageFiles(string host, string jobId, string directory): Get a list of image files.
  • public async Task<List<byte[]>> GetImageStreams(string host, string jobId): Get a list of image streams.
  • public async Task<<byte[]> GetImageStream(string host, string jobId): Get an image stream.
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • net7.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.1.0 303 10/25/2023
1.0.1 126 10/10/2023
1.0.0 107 10/10/2023

- Added GetImageStream() method to get the image stream from the scanner.