Skip to content

Commit 98259fd

Browse files
committedApr 27, 2025
Deploy preview for PR 247 🛫
1 parent d621855 commit 98259fd

File tree

335 files changed

+15930
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

335 files changed

+15930
-0
lines changed
 

‎pr-preview/pr-247/balloon.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
2+
# 📦 Scan Multiple Barcodes Samples
3+
4+
## 🚀 1. Hello World
5+
6+
This sample demonstrates how to use the `BarcodeScanner` API from the [Dynamsoft Barcode Reader JavaScript SDK](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/) to scan **multiple barcodes continuously** from a video stream in a web application.
7+
8+
### ✨ Features
9+
10+
- Scan multiple 1D/2D barcodes
11+
- Live video decoding using `BarcodeScanner` component
12+
- Easy integration into your web application
13+
- UI rendered into a customizable container
14+
15+
### 🔧 How It Works
16+
17+
The sample uses the `BarcodeScanner` class to launch a scanner and decode barcodes from a camera stream. The key configuration includes:
18+
19+
- **License Key** – Required to activate the SDK.
20+
- **`engineResourcePaths`** – Points to required resources hosted on a CDN or locally.
21+
- **UI container** – An HTML element where the scanner is rendered.
22+
23+
```ts
24+
const config = {
25+
license: "YOUR-LICENSE-KEY",
26+
engineResourcePaths: {
27+
// feel free to change it to your own path
28+
rootDirectory: "https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@10.5.1000/dist/",
29+
},
30+
container: ".barcode-scanner-view",
31+
scanMode: Dynamsoft.EnumScanMode.SM_MULTI_UNIQUE,
32+
showResultView: true,
33+
showUploadImageButton: true,
34+
scannerViewConfig: {
35+
showCloseButton: true
36+
},
37+
};
38+
```
39+
40+
The BarcodeScanner instance is created and launched like this:
41+
42+
```ts
43+
const barcodeScanner = new Dynamsoft.BarcodeScanner(config);
44+
barcodeScanner.launch();
45+
```
46+
47+
### 📌 Notes
48+
49+
- This sample scans **multiple unique barcodes**, you can configure `scanMode` to change the behavior to scan one single barcode.
50+
- To avoid network-related loading issues, consider hosting all required resources locally.
51+
52+
## 🛒 2. Cart Builder
53+
54+
This sample simulates a shopping experience where users scan barcodes to add items to a dynamic cart.
55+
56+
### ✨ Features
57+
58+
- Scan multiple 1D/2D barcodes
59+
- Live video decoding using `BarcodeScanner` component
60+
- Floating and draggable scanner window.
61+
- Dynamic cart updates on each scan.
62+
63+
### 🔧 How It Works
64+
65+
The scanning logic mirrors the Hello World sample, but scanned results populate the cart instead of just displaying in the result view.
66+
67+
The UI features a "Scan Barcode" button, a styled cart, and basic interactivity with vanilla JavaScript and CSS.
68+
69+
A list of 20 dummy products is used, with each scan randomly adding a product to the cart showing its name, shortened barcode, and price.
70+
71+
## 📄 See other BarcodeScanner samples
72+
73+
Multiple samples are provided for single barcode scanning. These samples can be easily adapted to scan multiple unique barcodes by simply updating the `config` object.
74+
75+
* [**Hello World**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode): Scan single barcode from video stream with minimum code in JavaScript.
76+
* [**Hello World in Angular**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/angular): Read single barcode from camera in an Angular application.
77+
* [**Hello World in React**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/react): Read single barcode from camera in a React application.
78+
* [**Hello World in Vue**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/vue): Read single barcode from camera in a Vue application.

0 commit comments

Comments
 (0)