-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhelloworld.js
More file actions
30 lines (29 loc) · 1.39 KB
/
helloworld.js
File metadata and controls
30 lines (29 loc) · 1.39 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
let Dynamsoft = require('../../dist/dbr.js');
// Please visit https://www.dynamsoft.com/CustomerPortal/Portal/TrialLicense.aspx to get trial license.
Dynamsoft.BarcodeReader.productKeys = 't0068MgAAAAHm/BLxlpvtBS6s6pr9dWqDugGIHret74wFrw+eZ7Z3JWD+Azscfy4pAxlKuHpdJ782DRVNgJYMASf9IWD3gK8=';
(async()=>{
console.log("============== create reader ==============");
let reader = await Dynamsoft.BarcodeReader.createInstance();
console.log("============== decode buffer ==============");
let fs = require('fs');
let buffer = fs.readFileSync(__dirname + '/../sample.png');
for(let result of await reader.decode(buffer)){
console.log(result.barcodeText);
}
console.log("============== decode base64 ==============");
let strBase64 = buffer.toString('base64');
for(let result of await reader.decodeBase64String(strBase64)){
console.log(result.barcodeText);
}
console.log("============== decode file ==============");
for(let result of await reader.decode(__dirname + '/../sample.png')){
console.log(result.barcodeText);
}
console.log("============== decode url ==============");
for(let result of await reader.decode('https://demo.dynamsoft.com/dbr/img/AllSupportedBarcodeTypes.png')){
console.log(result.barcodeText);
}
console.log("============== destroy reader ==============");
reader.destroy();
process.exit();
})();