Skip to content

Instantly share code, notes, and snippets.

@yushulx
Created December 7, 2017 02:15
Show Gist options
  • Save yushulx/6ae4faef2457bc6f07adc6d5bff2cb21 to your computer and use it in GitHub Desktop.
Save yushulx/6ae4faef2457bc6f07adc6d5bff2cb21 to your computer and use it in GitHub Desktop.
How to Use Dynamic Web TWAIN with Dojo
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial: Hello Dojo!</title>
<link rel="stylesheet" href="bower_components/dijit/themes/claro/claro.css">
<script>dojoConfig = {parseOnLoad: true}</script>
<script src="bower_components/dojo/dojo.js"></script>
<script type="text/javascript" src="https://www.dynamsoft.com/library/dwt/dynamsoft.webtwain.min.js"></script>
<script>
require(["dijit/form/Button", "dojo/dom", "dojo/domReady!"], function (Button, dom) {
var myButton = new Button({
label: "Scan Documents",
onClick: function () {
var DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
DWObject.IfDisableSourceAfterAcquire = true;
var bSelected = DWObject.SelectSource();
if (bSelected) {
var OnAcquireImageSuccess, OnAcquireImageFailure;
OnAcquireImageSuccess = OnAcquireImageFailure = function () {
DWObject.CloseSource();
};
DWObject.OpenSource();
DWObject.AcquireImage(OnAcquireImageSuccess, OnAcquireImageFailure);
}
}
}, "acquireImage").startup();
});
</script>
</head>
<body class="claro">
<h1 id="greeting">Dynamic Web TWAIN with Dojo</h1>
<button id="acquireImage" type="button"></button>
<div id="dwtcontrolContainer"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment