We have an intranet-based application, and users have desktop scanners (which are TWIAN but not WIA compatible). Users need to 'click to scan' from the browser window (IE 8) and save the scanned image to the application with minimal user-interaction.
I've got a c# winform app with this functionality, but I'm struggling to integrate it with the browser (IE 8).
I have considered:
- A Browser-Help开发者_如何学Goer Object calling the winform app as a dll
- A BHO with its own implementation of the scan functionality
- Silverlight
Are there any other approaches I should consider?
What I've got so far is pretty COM-heavy, based on this question/answer and using the .NET TWAIN samples at code project.
Is Siverlight an option for you? (Will your customers install it) If so having a single Siverlight page for scanning may be the best option.
Can the scanner be setup to email scanned images, if so you could have your web app read images that was emailed to it.
As you already know WinForm, maybe a small “click once” winform app that does the scanning – this depends on the customers being willing to install the .net framework.
(There are still some things that are a pain in the neck for Web Apps, but customers asked for WebApp as they want “nothing to install”)
Scanner.js acquires images from TWAIN WIA scanners and webcams in your browser. The output can be returning the images to the web page, uploading to the server directly, or in your case, saving to the local disk.
<html lang="en">
<head>
<script src="//asprise.azureedge.net/scannerjs/scanner.js" type="text/javascript"></script>
<script>
function scanToLocalDisk() {
scanner.scan(displayResponseOnPage,
{
"twain_cap_setting" : {
"ICAP_PIXELTYPE" : "TWPT_RGB", // Color
"ICAP_SUPPORTEDSIZES" : "TWSS_USLETTER" // Paper size: TWSS_USLETTER, TWSS_A4, ...
},
"output_settings": [
{
"type": "save",
"format": "pdf",
"save_path": "C:\\myfolder\\${TMS}${EXT}"
}
]
}
);
}
function displayResponseOnPage(successful, mesg, response) {
if(!successful) { // On error
document.getElementById('response').innerHTML = 'Failed: ' + mesg;
return;
}
if(successful && mesg != null && mesg.toLowerCase().indexOf('user cancel') >= 0) { // User cancelled.
document.getElementById('response').innerHTML = 'User cancelled';
return;
}
document.getElementById('response').innerHTML = scanner.getSaveResponse(response);
}
</script>
</head>
<body>
<h2>Scan to Local Disk</h2>
<button type="button" onclick="scanToLocalDisk();">Scan</button>
<div id="response"></div>
</body> </html>
When specifying the value for save_path
, you may use variables which will be expanded. For example, ${TMS} will be expanded as timestamp and ${EXT} as file extension.
Scanner.js supports in browser web twain image acquisition in formats like JPG, multi-page PDF, PNG, etc.
Read the developer guide to JavaScript web twain scanning for browsers (Chrome, Edge, Firefix and IE).
精彩评论