RazorWebTWAIN 0.1.2

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

// Install RazorWebTWAIN as a Cake Tool
#tool nuget:?package=RazorWebTWAIN&version=0.1.2

Razor Web TWAIN

A Razor class library for Dynamic Web TWAIN. It allows you to add document scanning functionality to your Blazor applications.

Dynamic Web TWAIN Version

v18.1

Prerequisites

Quick Start

  1. Import the RazorWebTWAIN package in the _Imports.razor file:

    @using RazorWebTWAIN
    
  2. Add the following code to your razor page:

    @page "/"
    @inject IJSRuntime JSRuntime
    @using System.Text.Json;
    
    <h1> Dynamic Web TWAIN Sample</h1>
    <select id="sources"></select>
    <br />
    <button @onclick="AcquireImage">Scan Documents</button>
    <button @onclick="LoadDocument">Load Documents</button>
    <button @onclick="RemoveSelected">Remove Selected</button>
    <button @onclick="RemoveAll">Remove All</button>
    <button @onclick="Save">Download Documents</button>
    
    <div id="document-container"></div>
    
    @code {
        JsInterop jsInterop;
        protected override void OnInitialized()
        {
            jsInterop = new JsInterop(JSRuntime);
        }
    
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            if (firstRender)
            {
                await jsInterop.LoadDWT("LICENSE-KEY");
                await jsInterop.InitContainer("document-container", 640, 640);
                await jsInterop.GetDevices("sources");
            }
        }
    
        public async Task AcquireImage()
        {
            // https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#acquireimageasync
            var deviceConfiguration = new {
                IfShowUI = false,
                PixelType = PixelType.TWPT_RGB,
                Resolution = 300,
                IfFeederEnabled = true,
                IfDuplexEnabled = false,
                IfDisableSourceAfterAcquire = true,
                IfGetImageInfo = true,
                IfGetExtImageInfo = true,
                extendedImageInfoQueryLevel = 0
            };
            // serialize the object to a JSON string
            var jsonString = JsonSerializer.Serialize(deviceConfiguration);
    
            await jsInterop.AcquireImage(jsonString);
    
        }
    
        public async Task LoadDocument()
        {
            await jsInterop.LoadDocument();
        }
    
        public async Task RemoveSelected()
        {
            await jsInterop.RemoveSelected();
        }
    
        public async Task RemoveAll()
        {
            await jsInterop.RemoveAll();
        }
    
        public async Task Save()
        {
            await jsInterop.Save(ImageType.PDF, "test");
        }
    }
    
    
  3. Run your project.

Example

Product 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-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
0.1.2 217 4/25/2023
0.1.1 141 4/25/2023
0.1.0 147 4/25/2023

- Fixed PDF error
- Fixed mac package download