Skip to content

Commit b848aa4

Browse files
committed
sync main brunch changes & update to v11.2.4000
1 parent 4efebaf commit b848aa4

File tree

3 files changed

+38
-30
lines changed

3 files changed

+38
-30
lines changed

programming/javascript/api-reference/barcode-scanner.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ interface BarcodeScannerConfig {
178178
// engineResourcePaths typically is only assigned when using a framework like React/Angular/Vue where the resources are not in the same location as the script reference.
179179
engineResourcePaths: {rootDirectory:"https://cdn.jsdelivr.net/npm/"},
180180
// path to the UI file
181-
uiPath: "https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.2.2000/dist/ui/barcode-scanner.ui.xml",
181+
uiPath: "https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.2.4000/dist/ui/barcode-scanner.ui.xml",
182182
barcodeFormats: [Dynamsoft.DBR.EnumBarcodeFormat.BF_QR_CODE , Dynamsoft.DBR.EnumBarcodeFormat.BF_CODE_128],
183183
showPoweredByDynamsoft: false,
184184
duplicateForgetTime: 3000,

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ layout: default-layout
33
needAutoGenerateSidebar: true
44
needGenerateH3Content: true
55
noTitleIndex: true
6-
title: User Guide - Dynamsoft Barcode Scanner v11.2.2000 JavaScript Edition
6+
title: User Guide - Dynamsoft Barcode Scanner v11.2.4000 JavaScript Edition
77
keywords: Documentation, Barcode Scanner, Dynamsoft Barcode Scanner JavaScript Edition,
88
description: Dynamsoft Barcode Scanner User Guide
99
---
1010

1111
# Build a Web-Based Barcode Scanner Using Just a Few Lines of JavaScript
1212

1313
<!-- Don't forget to add the TOC & update license section, which is useful for npm README.-->
14-
<!-- - [Build a Web-Based Barcode Scanner Using Just a Few Lines of JavaScript](#build-a-web-based-barcode-scanner-using-just-a-few-lines-of-javascript)
14+
- [Build a Web-Based Barcode Scanner Using Just a Few Lines of JavaScript](#build-a-web-based-barcode-scanner-using-just-a-few-lines-of-javascript)
1515
- [License](#license)
1616
- [Quick Start: Hello World Example](#quick-start-hello-world-example)
1717
- [Step 1: Setting up the HTML and Including the Barcode Scanner](#step-1-setting-up-the-html-and-including-the-barcode-scanner)
1818
- [Step 2: Initializing the Barcode Scanner](#step-2-initializing-the-barcode-scanner)
1919
- [Step 3: Launching the Barcode Scanner](#step-3-launching-the-barcode-scanner)
20-
- [Next Steps](#next-steps) -->
20+
- [Next Steps](#next-steps)
2121

2222
This user guide provides a step-by-step walkthrough of a "Hello World" web application using the `BarcodeScanner` JavaScript Edition.
2323

@@ -54,19 +54,19 @@ new Dynamsoft.BarcodeScanner().launch().then(result=>alert(result.barcodeResults
5454
5555
## License
5656

57-
<!-- When getting started with Barcode Scanner, we recommend [getting your own 30-day trial license](https://www.dynamsoft.com/customer/license/trialLicense/?product=dbr&utm_source=guide&package=js) -->
57+
When getting started with Barcode Scanner, we recommend [getting your own 30-day trial license](https://www.dynamsoft.com/customer/license/trialLicense/?product=dbr&utm_source=guide&package=js)
5858

59-
When getting started with Barcode Scanner, we recommend getting your own 30-day trial license.
59+
<!-- When getting started with Barcode Scanner, we recommend getting your own 30-day trial license.
6060
61-
{% include trialLicense.html %}
61+
{% include trialLicense.html %} -->
6262

6363
## Quick Start: Hello World Example
6464

6565
```html
6666
<!DOCTYPE html>
6767
<html lang="en">
6868
<body>
69-
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.2.2000/dist/dbr.bundle.js"></script>
69+
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.2.4000/dist/dbr.bundle.js"></script>
7070
<script>
7171
// Initialize the Dynamsoft Barcode Scanner
7272
const barcodeScanner = new Dynamsoft.BarcodeScanner({
@@ -87,30 +87,30 @@ When getting started with Barcode Scanner, we recommend getting your own 30-day
8787
```
8888

8989
<p align="center" style="text-align:center; white-space: normal; ">
90-
<a target="_blank" href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v11.2.20/barcode-scanner-api-samples/scan-single-barcode/hello-world.html" title="Code in Github" style="text-decoration:none;">
90+
<a target="_blank" href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v11.2.40/barcode-scanner-api-samples/scan-single-barcode/hello-world.html" title="Code in Github" style="text-decoration:none;">
9191
<img src="https://cdn.jsdelivr.net/npm/simple-icons@3.0.1/icons/github.svg" alt="Code in Github" width="20" height="20" style="width:20px;height:20px;">
9292
</a>
9393
&nbsp;
9494
<a target="_blank" href="https://jsfiddle.net/DynamsoftTeam/gcqjf5r7/" title="Run via JSFiddle" style="text-decoration:none;">
9595
<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;" >
9696
</a>
9797
&nbsp;
98-
<a target="_blank" href="https://demo.dynamsoft.com/Samples/DBR/JS/barcode-scanner-api-samples/scan-single-barcode/hello-world.html?ver=11.2.20&utm_source=guide" title="Run in Dynamsoft" style="text-decoration:none;">
98+
<a target="_blank" href="https://demo.dynamsoft.com/Samples/DBR/JS/barcode-scanner-api-samples/scan-single-barcode/hello-world.html?ver=11.2.40&utm_source=guide" title="Run in Dynamsoft" style="text-decoration:none;">
9999
<img src="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.0.0/svgs/solid/circle-play.svg" alt="Run in Dynamsoft" width="20" height="20" style="width:20px;height:20px;">
100100
</a>
101101
</p>
102102

103103
### Step 1: Setting up the HTML and Including the Barcode Scanner
104104

105-
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/v11.2.20).
105+
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/v11.2.40).
106106

107107
The first step before writing the code is to include the SDK in your application. You can simply include the SDK by using the precompiled script.
108108

109109
```html
110110
<!DOCTYPE html>
111111
<html lang="en">
112112
<body>
113-
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.2.2000/dist/dbr.bundle.js"></script>
113+
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.2.4000/dist/dbr.bundle.js"></script>
114114
</body>
115115
</html>
116116
```
@@ -127,21 +127,21 @@ The simplest way to include the SDK is to use either the [**jsDelivr**](https://
127127
- jsDelivr
128128

129129
```html
130-
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.2.2000/dist/dbr.bundle.js"></script>
130+
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.2.4000/dist/dbr.bundle.js"></script>
131131
```
132132

133133
- UNPKG
134134

135135
```html
136-
<script src="https://unpkg.com/dynamsoft-barcode-reader-bundle@11.2.2000/dist/dbr.bundle.js"></script>
136+
<script src="https://unpkg.com/dynamsoft-barcode-reader-bundle@11.2.4000/dist/dbr.bundle.js"></script>
137137
```
138138

139139
When using a framework such as **React**, **Vue** or **Angular**, we recommend adding the package as a dependency using a package manager such as **npm** or **yarn**:
140140

141141
```sh
142-
npm i dynamsoft-barcode-reader-bundle@11.2.2000
142+
npm i dynamsoft-barcode-reader-bundle@11.2.4000
143143
# or
144-
yarn add dynamsoft-barcode-reader-bundle@11.2.2000
144+
yarn add dynamsoft-barcode-reader-bundle@11.2.4000
145145
```
146146

147147
When using package managers like **npm** or **yarn**, you likely need to specify the location of the engine files as a link to a CDN. Please see the [BarcodeScannerConfig API](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/barcode-scanner.html#barcodescannerconfig) for a code snippet on how to set the `engineResourcePaths`.
@@ -154,14 +154,14 @@ Alternatively, you may choose to download the SDK and host the files on your own
154154

155155
- From the website
156156

157-
[Download Dynamsoft Barcode Reader JavaScript Package](https://www.dynamsoft.com/barcode-reader/downloads/?ver=11.2.20&utm_source=guide&product=dbr&package=js)
157+
[Download Dynamsoft Barcode Reader JavaScript Package](https://www.dynamsoft.com/barcode-reader/downloads/?ver=11.2.40&utm_source=guide&product=dbr&package=js)
158158

159159
The resources are located in the `./dist/` directory.
160160

161161
- From npm
162162

163163
```sh
164-
npm i dynamsoft-barcode-reader-bundle@11.2.2000
164+
npm i dynamsoft-barcode-reader-bundle@11.2.4000
165165
```
166166

167167
The resources are located at the path `node_modules/<pkg>`, without `@<version>`. You can copy it elsewhere and add `@<version>` tag.
@@ -172,7 +172,7 @@ Alternatively, you may choose to download the SDK and host the files on your own
172172
You can typically include the SDK like this:
173173

174174
```html
175-
<script src="path/to/dynamsoft-barcode-reader-bundle@11.2.2000/dist/dbr.bundle.js"></script>
175+
<script src="path/to/dynamsoft-barcode-reader-bundle@11.2.4000/dist/dbr.bundle.js"></script>
176176
```
177177
<div class="multi-panel-end"></div>
178178

@@ -228,5 +228,5 @@ Now that the Barcode Scanner has been initialized and configured, it is ready to
228228
Now that you've implemented the basic functionality, here are some recommended next steps to further explore the capabilities of the Barcode Scanner:
229229

230230
1. Learn how to [Customize the Barcode Scanner](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/barcode-scanner-customization.html)
231-
2. Check out the [Official Samples and Demo](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/samples-demos/index.html?ver=11.2.2000)
232-
3. Learn about the [APIs of BarcodeScanner](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/barcode-scanner.html?ver=11.2.2000)
231+
2. Check out the [Official Samples and Demo](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/samples-demos/index.html?ver=11.2.4000)
232+
3. Learn about the [APIs of BarcodeScanner](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/barcode-scanner.html?ver=11.2.4000)

programming/javascript/user-guide/index.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -504,15 +504,23 @@ await cvRouter.startCapturing("ReadSingleBarcode");
504504
Please be aware that it is necessary to update the `CapturedResultReceiver` object to obtain the original image. For instance:
505505
506506
```javascript
507-
const EnumCRIT = Dynamsoft.Core.EnumCapturedResultItemType;
508-
resultReceiver.onDecodedBarcodesReceived = (result) => {
509-
if (result.barcodeResultItems?.length) {
510-
// Use a filter to get the image on which barcodes are found.
511-
let image = result.items.filter(
512-
item => item.type === EnumCRIT.CRIT_ORIGINAL_IMAGE
513-
)[0].imageData;
514-
}
515-
};
507+
const EnumCRIT = Dynamsoft.Core.EnumCapturedResultItemType; // Enum for captured result item types.
508+
// Create a result receiver to handle the results.
509+
cvRouter.addResultReceiver({
510+
// This function is called when any capture result is received.
511+
onCapturedResultReceived: (result) => {
512+
//Check for barcode results
513+
let barcodeResultItems = result.items.filter((item) => item.type === EnumCRIT.CRIT_BARCODE);
514+
if (barcodeResultItems.length > 0) {
515+
let image = result.items.filter((item) => item.type === EnumCRIT.CRIT_ORIGINAL_IMAGE)[0]?.imageData; // Retrieve the original image.
516+
if (image) document.body.appendChild(image.toCanvas()); // Append the image to DOM.
517+
for (let item of barcodeResultItems) {
518+
// Print each barcode result to the console.
519+
console.log(`Barcode: ${item.text}, Format: ${item.formatString}`);
520+
}
521+
}
522+
},
523+
});
516524
```
517525
518526
#### 1.3. Change reading frequency to save power

0 commit comments

Comments
 (0)