Skip to content

Commit 9ba10fa

Browse files
authored
Merge pull request #158 from Dynamsoft/_dev
Dev
2 parents 39d6569 + 04f5b03 commit 9ba10fa

File tree

68 files changed

+7218
-8148
lines changed

Some content is hidden

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

68 files changed

+7218
-8148
lines changed

README.html

Lines changed: 26 additions & 48 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 26 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
# Barcode Scanner JavaScript Edition - User Guide
2-
3-
- [Barcode Scanner JavaScript Edition - User Guide](#barcode-scanner-javascript-edition---user-guide)
4-
- [License](#license)
5-
- [Trial License](#trial-license)
6-
- [Full License](#full-license)
7-
- [Quick Start: Hello World Example](#quick-start-hello-world-example)
8-
- [Step 1: Setting up the HTML and Including the Barcode Scanner](#step-1-setting-up-the-html-and-including-the-barcode-scanner)
9-
- [Step 2: Initializing the Barcode Scanner](#step-2-initializing-the-barcode-scanner)
10-
- [Step 3: Launching the Barcode Scanner](#step-3-launching-the-barcode-scanner)
11-
- [Next Steps](#next-steps)
1+
# Build a Web-Based Barcode Scanner Using Just a Few Lines of JavaScript
122

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

@@ -69,16 +59,8 @@ If you are fully satisfied with the solution and would like to move forward with
6959
```html
7060
<!DOCTYPE html>
7161
<html lang="en">
72-
<head>
73-
<meta charset="utf-8" />
74-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
75-
<title>Dynamsoft Barcode Scanner - Hello World</title>
76-
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/dbr.bundle.js"></script>
77-
</head>
78-
7962
<body>
80-
<h1 style="font-size: large">Dynamsoft Barcode Scanner</h1>
81-
63+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/dbr.bundle.js"></script>
8264
<script>
8365
// Initialize the Dynamsoft Barcode Scanner
8466
const barcodeScanner = new Dynamsoft.BarcodeScanner({
@@ -88,47 +70,42 @@ If you are fully satisfied with the solution and would like to move forward with
8870
(async () => {
8971
// Launch the scanner and wait for the result
9072
const result = await barcodeScanner.launch();
91-
alert(result.barcodeResults[0].text);
73+
// Display the first detected barcode's text in an alert
74+
if (result.barcodeResults.length) {
75+
alert(result.barcodeResults[0].text);
76+
}
9277
})();
9378
</script>
9479
</body>
9580
</html>
9681
```
9782

9883
<p align="center" style="text-align:center; white-space: normal; ">
99-
<a target="_blank" href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.5.30/scan-single-barcode/hello-world/hello-world.html" title="Code in Github" style="text-decoration:none;">
84+
<a target="_blank" href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v11.0.30/barcode-scanner-api-samples/scan-single-barcode/hello-world.html" title="Code in Github" style="text-decoration:none;">
10085
<img src="https://cdn.jsdelivr.net/npm/[email protected]/icons/github.svg" alt="Code in Github" width="20" height="20" style="width:20px;height:20px;">
10186
</a>
10287
&nbsp;
10388
<a target="_blank" href="https://jsfiddle.net/DynamsoftTeam/gcqjf5r7/" title="Run via JSFiddle" style="text-decoration:none;">
10489
<img src="https://cdn.jsdelivr.net/npm/[email protected]/icons/jsfiddle.svg" alt="Run via JSFiddle" width="20" height="20" style="width:20px;height:20px;" >
10590
</a>
10691
&nbsp;
107-
<a target="_blank" href="https://demo.dynamsoft.com/Samples/DBR/JS/barcode-scanner-api-samples/scan-single-barcode/hello-world.html?ver=10.5.30&utm_source=github" title="Run in Dynamsoft" style="text-decoration:none;">
92+
<a target="_blank" href="https://demo.dynamsoft.com/Samples/DBR/JS/barcode-scanner-api-samples/scan-single-barcode/hello-world.html?ver=11.0.30&utm_source=github" title="Run in Dynamsoft" style="text-decoration:none;">
10893
<img src="https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/svgs/solid/circle-play.svg" alt="Run in Dynamsoft" width="20" height="20" style="width:20px;height:20px;">
10994
</a>
11095
</p>
11196

11297
### Step 1: Setting up the HTML and Including the Barcode Scanner
11398

114-
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/v10.5.30).
99+
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.0.30).
115100

116101
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.
117102

118103
```html
119104
<!DOCTYPE html>
120105
<html lang="en">
121-
<head>
122-
<meta charset="utf-8" />
123-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
124-
<title>Dynamsoft Barcode Scanner - Hello World</title>
125-
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/dbr.bundle.js"></script>
126-
</head>
127-
128106
<body>
129-
<h1 style="font-size: large">Dynamsoft Barcode Scanner</h1>
107+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/dbr.bundle.js"></script>
130108
</body>
131-
132109
</html>
133110
```
134111

@@ -144,21 +121,21 @@ The simplest way to include the SDK is to use either the [**jsDelivr**](https://
144121
- jsDelivr
145122

146123
```html
147-
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@10.5.3000/dist/dbr.bundle.js"></script>
124+
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.0.3000/dist/dbr.bundle.js"></script>
148125
```
149126

150127
- UNPKG
151128

152129
```html
153-
<script src="https://unpkg.com/dynamsoft-barcode-reader-bundle@10.5.3000/dist/dbr.bundle.js"></script>
130+
<script src="https://unpkg.com/dynamsoft-barcode-reader-bundle@11.0.3000/dist/dbr.bundle.js"></script>
154131
```
155132

156133
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**:
157134

158135
```sh
159-
npm i dynamsoft-barcode-reader-bundle@10.5.3000
136+
npm i dynamsoft-barcode-reader-bundle@11.0.3000
160137
# or
161-
yarn add dynamsoft-barcode-reader-bundle@10.5.3000
138+
yarn add dynamsoft-barcode-reader-bundle@11.0.3000
162139
```
163140

164141
As for 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`.
@@ -171,25 +148,25 @@ Alternatively, you may choose to download the SDK and host the files on your own
171148

172149
- From the website
173150

174-
[Download Dynamsoft Barcode Reader JavaScript Package](https://www.dynamsoft.com/barcode-reader/downloads/?ver=10.5.30&utm_source=github&product=dbr&package=js)
151+
[Download Dynamsoft Barcode Reader JavaScript Package](https://www.dynamsoft.com/barcode-reader/downloads/?ver=11.0.30&utm_source=github&product=dbr&package=js)
175152

176-
The resources are located at path `dynamsoft/distributables/`.
153+
The resources are located in the `./dist/` directory.
177154

178155
- From npm
179156

180157
```sh
181-
npm i dynamsoft-barcode-reader-bundle@10.5.3000
158+
npm i dynamsoft-barcode-reader-bundle@11.0.3000
182159
```
183160

184-
The resources are located at the path `node_modules/<pkg>`, without `@<version>`. You can copy it elsewhere and add `@<version>` tag. One more thing to do is to [specify the engineResourcePaths](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/barcode-scanner.html#barcodescannerconfig) so that the SDK can correctly locate the resources.
161+
The resources are located at the path `node_modules/<pkg>`, without `@<version>`. You can copy it elsewhere and add `@<version>` tag.
185162

186163
> [!IMPORTANT]
187164
> Since "node_modules" is reserved for Node.js dependencies, and in our case the package is used only as static resources, we recommend either renaming the "node_modules" folder or moving the "dynamsoft-" packages to a dedicated folder for static resources in your project to facilitate self-hosting.
188165
189166
You can typically include SDK like this:
190167

191168
```html
192-
<script src="path/to/dynamsoft-barcode-reader-bundle@10.5.3000/dist/dbr.bundle.js"></script>
169+
<script src="path/to/dynamsoft-barcode-reader-bundle@11.0.3000/dist/dbr.bundle.js"></script>
193170
```
194171
<div class="multi-panel-end"></div>
195172

@@ -201,7 +178,7 @@ Barcode Scanner comes with a **Ready-to-Use UI**. When the Barcode Scanner launc
201178

202179
```js
203180
// Initialize the Dynamsoft Barcode Scanner
204-
const Barcodescanner = new Dynamsoft.BarcodeScanner({
181+
const barcodescanner = new Dynamsoft.BarcodeScanner({
205182
// Please don't forget to replace YOUR_LICENSE_KEY_HERE
206183
license: "YOUR_LICENSE_KEY_HERE",
207184
});
@@ -217,7 +194,6 @@ This is the **simplest** way to initialize the Barcode Scanner. The configuratio
217194
const barcodescanner = new Dynamsoft.BarcodeScanner({
218195
license: "YOUR_LICENSE_KEY_HERE",
219196
scanMode: Dynamsoft.EnumScanMode.SM_MULTI_UNIQUE,
220-
showResultView: true,
221197
});
222198
```
223199

@@ -227,7 +203,10 @@ const barcodescanner = new Dynamsoft.BarcodeScanner({
227203
(async () => {
228204
// Launch the scanner and wait for the result
229205
const result = await barcodescanner.launch();
230-
alert(result.barcodeResults[0].text);
206+
// Display the first detected barcode's text in an alert
207+
if (result.barcodeResults.length) {
208+
alert(result.barcodeResults[0].text);
209+
}
231210
})();
232211
```
233212

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

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

0 commit comments

Comments
 (0)