Skip to content

Commit 8187f34

Browse files
Add examples for scanning single and multiple barcodes in the user guide
1 parent ce95603 commit 8187f34

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

programming/javascript/user-guide/barcode-scanner.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ When getting started with Barcode Scanner, we recommend getting your own 30-day
6464

6565
## Quick Start: Hello World Example
6666

67+
Scan One Single Barcode via Camera
68+
6769
```html
6870
<!DOCTYPE html>
6971
<html lang="en">
@@ -102,6 +104,39 @@ When getting started with Barcode Scanner, we recommend getting your own 30-day
102104
</a>
103105
</p>
104106

107+
Scan Multiple Barcodes Continuously
108+
109+
```html
110+
<!DOCTYPE html>
111+
<html lang="en">
112+
<body>
113+
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.2.4000/dist/dbr.bundle.js"></script>
114+
<script>
115+
// Initialize the Dynamsoft Barcode Scanner
116+
const barcodeScanner = new Dynamsoft.BarcodeScanner({
117+
// Please don't forget to replace YOUR_LICENSE_KEY_HERE
118+
license: "YOUR_LICENSE_KEY_HERE",
119+
scanMode: Dynamsoft.EnumScanMode.SM_MULTI_UNIQUE,
120+
});
121+
(async () => {
122+
// Launch the scanner and wait for the result
123+
const result = await barcodeScanner.launch();
124+
if (result.barcodeResults.length) {
125+
// Log the full result object to the console for debugging or further processing
126+
console.log(result);
127+
}
128+
})();
129+
</script>
130+
</body>
131+
</html>
132+
```
133+
134+
<p align="center" style="text-align:center; white-space: normal; ">
135+
<a target="_blank" href="https://jsfiddle.net/DynamsoftTeam/d6comprf/" title="Run via JSFiddle" style="text-decoration:none;">
136+
<img src="https://cdn.jsdelivr.net/npm/simple-icons@3.0.1/icons/jsfiddle.svg" alt="Run via JSFiddle" width="20" height="20" style="width:20px;height:20px;" >
137+
</a>
138+
</p>
139+
105140
### Step 1: Setting up the HTML and Including the Barcode Scanner
106141

107142
As outlined earlier, this guide will help you create a simple Hello World barcode scanning application using vanilla JavaScript. The full sample code is also available in the [GitHub repository](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main).
@@ -202,6 +237,12 @@ This is the **simplest** way to initialize the Barcode Scanner. The configuratio
202237
const barcodeScanner = new Dynamsoft.BarcodeScanner({
203238
license: "YOUR_LICENSE_KEY_HERE",
204239
scanMode: Dynamsoft.EnumScanMode.SM_MULTI_UNIQUE,
240+
// onUniqueBarcodeScanned: (result) => {
241+
// console.log("Scanned barcode: ", result.text);
242+
// if (condition) { // You can add custom logic here to handle each scanned barcode
243+
// barcodeScanner.dispose(); // Stop scanning
244+
// }
245+
// },
205246
});
206247
```
207248

0 commit comments

Comments
 (0)