Skip to content

Commit 751d5be

Browse files
fix: update license initialization and update read-an-image.html
1 parent 03cde15 commit 751d5be

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

read-an-image.html

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,30 @@ <h1>Hello World (Read an Image)</h1>
2121

2222
<script>
2323
/** LICENSE ALERT - README
24-
* To use the library, you need to first specify a license key using the API "initLicense()" as shown below.
25-
*/
26-
27-
Dynamsoft.License.LicenseManager.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
28-
29-
/**
24+
* To use the library, you need to first specify a license key.
25+
*
3026
* You can visit https://www.dynamsoft.com/customer/license/trialLicense?utm_source=samples&product=dbr&package=js to get your own trial license good for 30 days.
3127
* Note that if you downloaded this sample from Dynamsoft while logged in, the above license key may already be your own 30-day trial license.
32-
* For more information, see https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/index.html?ver=11.2.4000&cVer=true#specify-the-license&utm_source=samples or contact support@dynamsoft.com.
28+
* For more information, see https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/barcode-scanner.html#license&utm_source=samples or contact support@dynamsoft.com.
3329
* LICENSE ALERT - THE END
3430
*/
31+
let config = {
32+
license: "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9",
33+
};
3534

36-
// Optional. Preload "BarcodeReader" module for reading barcodes. It will save time on the initial decoding by skipping the module loading.
37-
Dynamsoft.Core.CoreModule.loadWasm();
38-
const resultsContainer = document.querySelector("#results");
35+
// Create a new instance of the Dynamsoft Barcode Scanner
36+
barcodeScanner = new Dynamsoft.BarcodeScanner(config);
3937

40-
let cvRouter; // an instance of CaptureVisionRouter
41-
let pCvRouter; // promise of CaptureVisionRouter
38+
const resultsContainer = document.querySelector("#results");
4239

4340
document.querySelector("#input-file").addEventListener("change", async function () {
4441
let files = [...this.files];
4542
this.value = "";
4643
resultsContainer.innerText = "";
4744
try {
48-
cvRouter = cvRouter || (await (pCvRouter = pCvRouter || Dynamsoft.CVR.CaptureVisionRouter.createInstance()));
49-
5045
for (let file of files) {
5146
// Decode selected image with 'ReadBarcodes_SpeedFirst' template.
52-
const result = await cvRouter.capture(file, "ReadBarcodes_ReadRateFirst");
47+
const result = await barcodeScanner.decode(file, "ReadBarcodes_SpeedFirst");
5348
const barcodeResultItems = result.decodedBarcodesResult?.barcodeResultItems;
5449

5550
if (files.length > 1) {

0 commit comments

Comments
 (0)