Note: Before you begin, make sure you have downloaded and installed the latest version of Dynamic Web TWAIN. If you have not downloaded, you can click here to get 30-day free trial.
The following will show you how to quickly create a Web-based scanning applications within 5 minutes!
Step 1: Start the Web application
1.1 Dynamsoft the Resources folder to your project
Resources folder is usually found here C: \ Program Files (x86) \ Dynamsoft \ Dynamic Web TWAIN SDK { version} Trial \
1.2 Create an empty HTML page
please the HTML page with the Resources folder in the directory at the same level, as shown below:
Step 2: Dynamic Web TWAIN added to the HTML page
2.1 introduces two Dynamsoft JS files
<script type="text/javascript" src="Resources/dynamsoft.webtwain.initiate.js">
<script type="text/javascript" src="Resources/dynamsoft.webtwain.config.js">
2.2 Adding Dynamic Web TWAIN container
<div id =“dwtcontrolContainer”>
Note: "dwtcontrolContainer" div is the default ID. You can also change it in the file dynamsoft.webtwain.config.js.
Step 3: Using Dynamic Web TWAIN
3.1 Add "Scan" button and related code
<input type="button" value="Scan" onclick="AcquireImage();" />
<script type="text/javascript">
var DWObject;
function Dynamsoft_OnReady(){
DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
}
function AcquireImage(){
if(DWObject) {
DWObject.IfDisableSourceAfterAcquire = true;
DWObject.SelectSource();
DWObject.OpenSource();
DWObject.AcquireImage();
}
}
</script>
3.2 The full code
<html>
<head>
<title>Hello World</title>
<script type="text/javascript" src="Resources/dynamsoft.webtwain.initiate.js"> </script>
<script type="text/javascript" src="Resources/dynamsoft.webtwain.config.js"> </script>
</head>
<body>
<input type="button" value="Scan" onclick="AcquireImage();" />
<div id="dwtcontrolContainer"> </div>
<script type="text/javascript">
var DWObject;
function Dynamsoft_OnReady(){
DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
}
function AcquireImage(){
if(DWObject) {
DWObject.IfDisableSourceAfterAcquire = true;
DWObject.SelectSource();
DWObject.OpenSource();
DWObject.AcquireImage();
}
}
</script>
</body>
</html>
3.3 VIEW scan a page
if the page is opened Hello World in the project, can be as shown below:
You can click on the "Scan" button to select the device, as shown below:
Please note:
"Select Source" dialog box lists only the TWAIN compatible devices. If you do not have really a scanner, you can install developed by the TWAIN working group of virtual scanner for testing.
After the scan is complete, the image will be displayed in the built-in Dynamic Web TWAIN Viewer:
If you have a 30-day trial version of Dynamic Web TWAIN is installed, you can find a complete Hello World application C here: \ Program Files (x86) \ Dynamsoft \ Dynamic Web TWAIN SDK {version} Trial \ Samples \ Getting Started \ HelloWorld.html
At the same time, we have other sample code for your reference. Chinese distributor contact: 0571-89916678.