dwt
Version:
Dynamic Web TWAIN is a TWAIN/ICA/SANE-based scanning SDK software specifically designed for web applications running on Windows/macOS/Linux. With just a few lines of code, you can develop robust applications to scan documents from TWAIN/ICA/SANE-compatibl
64 lines (53 loc) • 2.61 kB
HTML
<html>
<head>
<title>Use Auto Feeder to scan</title>
<script type="text/javascript" src="../dist/dynamsoft.webtwain.min.js"></script>
</head>
<body>
<label>
<input type="checkbox" id="ADF" checked="checked">Auto Feeder</label>
<input type="button" value="Scan" onclick="AcquireImage();" />
<!-- dwtcontrolContainer is the default div id for Dynamic Web TWAIN control.
If you need to rename the id, you should also change the id in the dynamsoft.webtwain.config.js accordingly. -->
<div id="dwtcontrolContainer"></div>
<script type="text/javascript">
window.onload = function () {
Dynamsoft.WebTwainEnv.Load();
};
Dynamsoft.WebTwainEnv.ProductKey = 't0140cQMAAGnOvWTyoOR4HEFckJJmzMWpZcPSHyXGAvYGxgEkg5fBnRoFPslaAayuNOe5B/gp7plUCIUAtf6Ttb98d7Ifv/3A6Mxsu7CZLJhKHUuMorfuu/E/ZrOfuSyoMz7zjXKjgvHcMO1HiGbvyHv+GBWM54ZpP4Wej2RorGBUMJ4b4tx40yqnXlIiqvs='; //2020-04-24
Dynamsoft.WebTwainEnv.RegisterEvent('OnWebTwainReady', Dynamsoft_OnReady); // Register OnWebTwainReady event. This event fires as soon as Dynamic Web TWAIN is initialized and ready to be used
var DWObject;
function Dynamsoft_OnReady() {
DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer'); // Get the Dynamic Web TWAIN object that is embeded in the div with id 'dwtcontrolContainer'
}
function AcquireImage() {
if (DWObject) {
DWObject.SelectSource(function () {
var OnAcquireImageSuccess, OnAcquireImageFailure;
OnAcquireImageSuccess = OnAcquireImageFailure = function () {
DWObject.CloseSource();
};
DWObject.OpenSource();
DWObject.IfShowUI = false; //Disable scanner UI.
DWObject.IfDisableSourceAfterAcquire = true;//Scanner source will be disabled automatically after scan.
if (document.getElementById("ADF").checked)//Use auto feeder or use the flatbed
DWObject.IfFeederEnabled = true;//Enbale Document Feeder
else
DWObject.IfFeederEnabled = false;//Disable Document Feeder
if (document.getElementById("ADF").checked && DWObject.IfFeederEnabled == true) // if paper is NOT loaded on the feeder
{
if (DWObject.IfFeederLoaded != true && DWObject.ErrorCode == 0) {
if (confirm("No paper detected on the feeder, do you want to scan from the flatbed instead?"))
DWObject.IfFeederEnabled = false;
else
return;
}
}
DWObject.AcquireImage(OnAcquireImageSuccess, OnAcquireImageFailure);
}, function () { console.log('SelectSource failed!'); });
}
}
</script>
</body>
</html>