Home › Forums › TWAIN Direct › To get the list of scanners from javascript client side (browser)
- This topic is empty.
- AuthorPosts
- Hemant Dubey
We are working on an MVC application to scan the document from a twain direct based scanner which is installed in a LAN.
For the discovery of connected scanners, we are using Bonjour which exposes the list of scanners. The scanner (twain direct) also provides rest APIs to create session with the scanner, capturing data etc.
The limitation of this solution is that, it must be deployed on the same LAN where the scanners are connected. Then only, we are able to get the list of scanners using Bonjour (Dnssd).
Now, we want to modify the solution in a way, so that the application should be deployed out side the LAN and be able to get the list of available scanners of the LAN where the application is being accessed (In Browser).
We tried a package “https://www.npmjs.com/package/bonjour” but it seems to be a server side library. We also used browserfy to make a bundle.js for javascript but it did not worked.
If we can get the list of scanners in client LAN then, we will be able to use rest api with selected scanner to perform rest of the scanning tasks.
NOTE: On the expected LAN there may not be any PC (it may be only an ipad/android/iphone and scanner) to install any other supporting software for exposing list of scanners.
Thanks
MarkMTWAIN Cloud (which can be at the enterprise level) is the intended solution when going outside of the local subnet. There are security issues that come into play when exiting a LAN.
That said, Bonjour does have configurations that allow one to specify multiple hops (the default for TWAIN Local is one hop). If configured to broadcast the mDNS packet routers will pass that information to adjacent subnets. In additional to the security risk there is also a performance penalty for doing this sort of thing.
Note that if DNS is available on your network you could use that instead. All TWAIN Local needs is an IP address to establish the connection. How you get it is up to you.
ted robinsonScanner.js can do that.
Lists all scanners available optionally with capabilities
You use scanner.listSources to list all available scanners:List all scanners
function listSources() {
displayText(“Listing sources …”);
scanner.listSources(callbackFunc, false, “all”, true, true);
}function callbackFunc(successful, mesg, result) {
displayText((successful ? “OK” : “ERROR”) + (mesg ? ” – ” + mesg : “”) + “\n” + result);
}
listSources takes the following parameters in order:callbackFunc
The function to be called after the operation is done; required.nameOnly
boolean – if true, return list of device names separated by ‘,’ otherwise return device info in JSON format. Default: true.capsToRetrieve
boolean – only effective if nameOnly is false – If set, return JSON string; can be cap name or code separated by comma or ‘all’ to list all caps supported.detectDeviceType
boolean – detect whether the device has ADF and/or flatbed, default; falseexcludeTwainDsOnWia
boolean – exclude WIA synthesized sources; default: true - AuthorPosts