Open a ticket
Chat with us

TWTwainJS - Documentation

Whether you are new to the library or have experience using it, the documentation is full of useful information to help you get started, including detailed instructions on how to integrate TWTwainJS into your website or local web app.

Featured image TWTwainJS

How does it work?

TWTwainJS consists of two main parts:

1

TWTwainJS

Javascript


TWTwainJS connects to TWTwainClient by opening a socket connection from your website where you want to provide scanning functionality.

Requirement:

  • Web visitors must have already installed TWTwainClient on their computer

If you are a web developer, you are primarily interested in TWTwainJS.

Download
TWTwainJS.zip
Download Button TWTwainJs.zip

2

TWTwainClient

.NET Windows application


TWTwainClient is making communication with web visitors local scanners.

Requirements:

  • TWTwainClient is a .NET windows application, and it will work only on Windows OS (Windows Vista and newer)
  • Web visitor's scan devices must have a TWAIN driver

How to start using it?

If you are a web visitor of the website using TWTwainJS

1. Install TWTwainClient on your Windows OS machine.
2. Visit the web page where TWTwainJS is implemented

If you are a web developer implementing TWTwainJS on your website

Extract TWTwainJS.zip
Let's presume that you have index.html and index.js and you plan to support modern browsers which support ES2015

In index.js

import TWTwainJS, { ScanSettings, TWDeviceName, TWEvent, TWJSConnectionStatus } from "./src/TWTwainJS.js"; import { CapEnum, CapName } from "./src/TWTwainJSCapabilities.js"; const twTwainJS = new TWTwainJS("yourTwainInstance", "demoCompany", "demoKey"); twTwainJS .connectToClient(50000, 65535) // it will scan ports from 50000 to 65535 .then((result) => { if (result.status === TWJSConnectionStatus.CONNECTED) { let scanSettings = new ScanSettings(TWDeviceName.DEFAULT); scanSettings.showUI = true; scanSettings.closeUIAfterAcquire = true; scanSettings.scanFormatType = CapEnum.TWScanFormatType.JPEG; twTwainJS .scan(scanSettings) .then((result) => { console.log("scan finished with result:", result); }) .catch((error) => { console.log("scan finished with error:", error); }); } }) .catch((error) => { console.log("connectToClient error:", error); }); window.addEventListener(TWEvent.PAGE_SCANNED, function (e) { _scanResult = e.detail.scanResult; _currentPage = _scanResult.images.length; });

This simple example will try to open a socket connection with the TWTwainClient.
Once opened, it will scan on the local default device in the jpeg format. The scanner's settings dialog will be shown.
On every page scanned, TWEvent.PAGE_SCANNED is triggered with the scanned image in its detail.

For more examples of advanced use (like settings TWAIN capabilities, saving in different formats like PDF or TIFF, and downloading scanned results...), please visit the link provided via the button below.

Show me the examples

Licensing

To avoid a watermark on your scanned pages, you need a valid license key, which you will retrieve upon purchasing the product.
The license key is set on the TWTwainJS side using the following syntax:

const twTwainJS = new TWTwainJS("yourTwainJSInstanceName", "company", "licenseKey");

The license is based on the allowed domain names, which are set by the license owner during the purchase process.
The license allows usage on one domain and up to three subdomains, and it will only work on the domain names that have been explicitly allowed by the license owner.

For example, if your website is on the domain www.yourdomain.com and you set that as an allowed domain, the license will only work if the software is run on www.yourdomain.com or one of its allowed subdomains.

In addition to the licensing benefits, you will receive one year of free upgrades and support provided directly by our developers.

Where can I see a demo to test how it really works?

A fully functional demo with a watermark is available on the link provided via the button below.

Check out the demo!
Opens demo in a new tab
Demo Button TWTwainJS

The source code of that demo is available in the TWTwainJS.zip file.

Where can I use TWTwainJS?

It is written in plain JS, so it can be used in static sites, PHP, Django, and ASP.NET Core. It is web technology agnostic.
In TWTwainJS.zip is provided the ES6 Javascript version, which will work in modern browsers, and the ES5 version for older browsers.
TWTwainJS uses window, CustomEvent, and WebSocket object so:

  • it can't be used directly in the main process of the electron app, but it can be used in the renderer process
  • it can't be used in Node applications

How can I set TWTwainClient settings (socket port, save location folder)?

A fully functional demo with a watermark is available on the link provided via the button below.

Once installed, TWTwainClient has the option to set its settings.

Once started, you will see these settings options.


Additional resources

Javascript reference documentation

In this documentation, you can find comprehensive information on all the methods and properties offered by TWTwainJS. To get a better understanding of its potential use cases, you can also refer to the examples provided in the section below.

Javascript Reference

Javascript examples

Various examples on TWTwainJS component usage within the Javascript code.

Show me the examples

If you have additional questions, don't hesitate to contact us through the form below or at [email protected]


Questions? Contact us now
We provide support only in English.
TEHNICAL SUPPORT PHONE
(407) 567-0096
SALES PHONE
(407) 567-0097
Telephone support available from 10 AM till 10 PM Central European Time
Copyright © 2024 Terminalworks. All Rights Reserved