正如@Basic 提到的,JTwain可用于创建这样的解决方案。事实上,JTwain 的开发者已经创建了ScannerJS,它允许人们使用 JavaScript 直接从 IE、Chrome 和 Firefox 等浏览器进行扫描。为了在您的网页中使用它,您需要:
包括scanner.js:
<html lang="en"><head>
<script src="//asprise.azureedge.net/scannerjs/scanner.js" type="text/javascript"></script>
并致电scanner.scan
:
function scanToWebPageAndUploadToWebServer() {
scanner.scan(displayImagesOnPage,
{
"twain_cap_setting": {
"ICAP_PIXELTYPE": "TWPT_GRAY",
"ICAP_XRESOLUTION": "200",
"ICAP_YRESOLUTION": "200"
},
"prompt_scan_more": true,
"discard_blank_pages": "false",
"blank_page_threshold": "0.02",
"output_settings": [
{
"type": "return-base64-thumbnail",
"format": "jpg",
"thumbnail_height": 200
},
{
"type": "upload",
"format": "pdf",
"pdf_force_black_white": "false",
"pdfa_compliant": "false",
"pdf_text_line": "By ${USERNAME} on ${DATETIME}",
"exif": {
"DocumentName": "Doc Scan Powered by Asprise.com",
"UserComment": "Scanned using Asprise software"
},
"upload_target": {
"url": "https://asprise.com/scan/applet/upload.php?action=dump",
"max_retries": 2,
"post_fields": {
"provider": "Asprise"
},
"cookies": "name=Asprise; domain=asprise.com",
"auth": "user:pass",
"headers": [
"Referer: http://asprise.com"
],
"log_file": "null",
"max_operation_time": 600
}
}
]
}
);
}