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
88 lines (79 loc) • 4.06 kB
HTML
<html>
<head>
<title>Use Dynamic Web TWAIN to Scan With Thumbnails View</title>
<script src="../dist/dynamsoft.webtwain.min.js"></script>
</head>
<body style="padding: 30px;">
<input type="button" style="font-size: x-large;" value="Scan" onclick="AcquireImage();" class="btn bgBlue mb15 mr20" />
<input type="button" style="font-size: x-large;" value="Open a local file" onclick="LoadImages();" class="btn bgBlue mb15" />
<br />
<br />
<div style="display: block; position: absolute;" class="container">
<div id="dwtcontrolContainer" style="float: left; position:relative; margin-right:20px;"></div>
<div id="dwtcontrolContainerLargeViewer" style="float: left; position:relative;"></div>
</div>
<script type="text/javascript">
Dynamsoft.DWT.ResourcesPath = "../dist";
Dynamsoft.DWT.ProductKey = 't0078lQAAAA6/IlIbNC7kmlEwnoekMXbQCjKCIbXQPNX5YcTlkQ1q4R4g+O1GT800Pmu8OKFOEv81ye/RJPXBdG9de9pkHxXgXq2nohPqqh9G';
window.onload = function () {
if (Dynamsoft && (!Dynamsoft.Lib.product.bChromeEdition)) {
var ObjString = [];
ObjString.push('<div class="p15">');
ObjString.push("Please note that the sample doesn't work on your current browser, please use a modern browser like Chrome, Firefox, etc.");
ObjString.push('</div>');
Dynamsoft.DWT.ShowDialog(400, 180, ObjString.join(''));
if (document.getElementsByClassName("dynamsoft-dialog-close"))
document.getElementsByClassName("dynamsoft-dialog-close")[0].style.display = "none";
} else {
Dynamsoft.DWT.Containers = [{ContainerId:'dwtcontrolContainer', Width:300, Height:800}];
Dynamsoft.DWT.Load();
}
};
Dynamsoft.DWT.AutoLoad = false;
Dynamsoft.DWT.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.DWT.GetWebTwain('dwtcontrolContainer'); // Get the Dynamic Web TWAIN object that is embeded in the div with id 'dwtcontrolContainer'
if (DWObject) {
DWObject.Viewer.width = 300;
DWObject.Viewer.height = 800;
DWObject.Viewer.cursor = "default";
Dynamsoft.DWT.CustomizableDisplayInfo.buttons.visibility.close = false;
DWObject.Viewer.setViewMode(1, 4); // Set the view mode to 1 by 4
DWObject.ShowImageEditor("dwtcontrolContainerLargeViewer", 750, 800);
}
}
function AcquireImage() {
if (DWObject) {
DWObject.SelectSource(function () {
var OnAcquireImageSuccess, OnAcquireImageFailure;
OnAcquireImageSuccess = OnAcquireImageFailure = function () {
DWObject.CloseSource();
};
DWObject.OpenSource();
DWObject.IfDisableSourceAfterAcquire = true;
DWObject.AcquireImage(OnAcquireImageSuccess, OnAcquireImageFailure);
}, function () {
console.log('SelectSource failed!');
});
}
}
function LoadImages() {
if (DWObject) {
if (DWObject.Addon && DWObject.Addon.PDF) {
DWObject.Addon.PDF.SetResolution(300);
DWObject.Addon.PDF.SetConvertMode(Dynamsoft.DWT.EnumDWT_ConvertMode.CM_RENDERALL);
}
DWObject.LoadImageEx('', 5,
function () {
},
function (errorCode, errorString) {
alert('Load Image:' + errorString);
}
);
}
}
</script>
</body>
</html>