-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathrequirejs-decodeFile.html
More file actions
39 lines (36 loc) · 1.65 KB
/
Copy pathrequirejs-decodeFile.html
File metadata and controls
39 lines (36 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<html>
<body>
<input id="iptDecodeImg" type="file" accept="image/bmp,image/jpeg,image/png,image/gif">
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script>
<script>
// Warning: Use a specific version in production. (e.g. https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@x.x.x/dist/dbr.min.js)
requirejs(['https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode/dist/dbr.min.js'], function(BarcodeReader){
// Visit https://www.dynamsoft.com/CustomerPortal/Portal/TrialLicense.aspx to get key.
BarcodeReader.licenseKey = "t0068MgAAAAxT9peWqAbLNI2gDlg9yk8dqzhp5Me5BNCgFIg2p5X+8TPYghCr9cz6TNFlkmkpzOJelNHJaQMWGe7Bszoxoo4=";
let reader;
BarcodeReader.createInstance().then(r => reader = r );
document.getElementById('iptDecodeImg').addEventListener('change', function(){
if(!reader){return;}
reader.decode(this.files[0]).then(results => {
if(results.length > 0)
{
console.log(results);
var txts = [];
for(var i = 0; i < results.length; ++i){
txts.push(results[i].BarcodeText);
}
alert(txts.join("\n"));
this.value = '';
}
else
{
alert("No barcode found.");
this.value = '';
}
});
});
});
</script>
</body>
</html>