Constructor
#
new TWTwainJS(name, companyName, key, twConsole)
Creates an instance of TWTwainJS.
Parameters:
Name |
Type |
Description |
name |
string
|
The name of the TWTwainJS instance. |
companyName |
string
|
License company name |
key |
string
|
License key |
twConsole |
object
|
The console object to be used for logging. Used only for debugging purposes. |
Members
#
id :string
The id of the twTwainJS instance. It is set automatically when the connect method succeeds.
Basic information about the twTwainJS instance.
#
name :string
The name of the TWTwainJS instance.
#
port :number
The port used for the socket communication. It is set automatically when the connect method succeeds.
The result of the last scan.
Methods
#
connectToClient(fromPort, fromPort) → {Promise}
Connect to the TWTwain client and open the WebSocket connection trying to
find a first valid port in the from and to range.
If the connection is successful, the onConnected event is raised otherwise No valid socket found is raised.
Parameters:
Name |
Type |
Description |
fromPort |
number
|
The starting port number in client port range. |
fromPort |
number
|
The ending port number in client port range. |
Returns:
- A promise that resolves when the connection is successful.
-
Type
-
Promise
#
downloadFile(downloadMode, settings) → {Promise}
Download the specified file in the file format specified in the fileName extension.
For every single file downloaded, TWEvent.SINGLE_FILE_DOWNLOADED is triggered.
Once all the files are downloaded, TWEvent.DOWNLOAD_FINISHED is triggered.
Parameters:
Name |
Type |
Description |
downloadMode |
TWDownloadMode
|
download mode. Allowed values are TWDownloadMode.LOCAL ("local") or TWDownloadMode.STANDARD ("standard").
Local mode saves the file to the local machine based on TWTwain client settings.
Standard mode uses the browser's download functionality. |
settings |
ScannedFileSettings
|
Scanned file settings. |
Returns:
- Promise object represents the download result.
-
Type
-
Promise
#
getAvailableDevices() → {Promise}
Execute retrieving the available devices and current default device from the client.
Once finished, event TWWEvent.DEVICE_LIST_RETRIEVED is triggered.
Returns:
- Promise object represents the available devices retrieve result.
-
Type
-
Promise
#
getCurrentSettings(capNames, deviceName) → {Promise}
Execute retrieving the current capability values from the client.
Once finished, event TWEvent.CURRENT_SETTINGS_RECEIVED is triggered.
Parameters:
Name |
Type |
Description |
capNames |
*
|
Array of capability names to retrieve the values for. |
deviceName |
string
|
Name of the device to retrieve the capabilities from. |
Returns:
- Promise object represents the current settings retrieve result.
-
Type
-
Promise
#
getDeviceInfo(deviceName, ignoreCurrentValues) → {Promise}
Open the specified scanner device and reads its capabilities and current values.
Once opened, event TWEvent.DEVICE_INFO_RETRIEVIED is triggered with the device name and capabilities in the detail.
Parameters:
Name |
Type |
Default |
Description |
deviceName |
string
|
|
Name of the device to open. |
ignoreCurrentValues |
boolean
|
false
|
If true, the current values of the capabilities are not retrieved. It could be good for performance.
Default is false. |
Returns:
- Promise object represents the device info.
-
Type
-
Promise
#
getFile(settings) → {Promise}
Retrieves the specified file(s) in the file format specified in the fileName extension.
For every single file retrieved, TWEvent.SINGLE_FILE_RETRIEVED is triggered.
Once all the files are retrieved, TWEvent.FILE_RETRIEVE_FINISHED is triggered.
Returns:
- Promise object represents the file retrieve result.
-
Type
-
Promise
#
scan(scanSettings) → {Promise}
Execute scanning from the TWTwain client using the specified settings in capability property.
Once the page is scanned, TWEvent.PAGE_SCANNED is triggered.
Once the scanning finishes, TWEvent.SCAN_FINISHED is triggered with scanFinishedStatus set to
TWScanFinishedStatus.SUCCESS if the scanning is successful
or TWScanFinishedStatus.ERROR if the scanning is not successful
or TWScanFinishedStatus.CANCEL if the scanning is cancelled.
Parameters:
Name |
Type |
Description |
scanSettings |
ScanSettings
|
Scan settings. |
Returns:
- Promise object represents the scan result.
-
Type
-
Promise