You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<atarget="_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
+
<atarget="_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;">
100
85
<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;">
101
86
</a>
102
87
103
88
<atarget="_blank"href="https://jsfiddle.net/DynamsoftTeam/gcqjf5r7/"title="Run via JSFiddle"style="text-decoration:none;">
104
89
<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;" >
105
90
</a>
106
91
107
-
<atarget="_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
+
<atarget="_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;">
108
93
<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;">
109
94
</a>
110
95
</p>
111
96
112
97
### Step 1: Setting up the HTML and Including the Barcode Scanner
113
98
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).
115
100
116
101
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.
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**:
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
The resources are located at path `dynamsoft/distributables/`.
153
+
The resources are located in the `./dist/` directory.
177
154
178
155
- From npm
179
156
180
157
```sh
181
-
npm i dynamsoft-barcode-reader-bundle@10.5.3000
158
+
npm i dynamsoft-barcode-reader-bundle@11.0.3000
182
159
```
183
160
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.
185
162
186
163
> [!IMPORTANT]
187
164
> 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.
@@ -201,7 +178,7 @@ Barcode Scanner comes with a **Ready-to-Use UI**. When the Barcode Scanner launc
201
178
202
179
```js
203
180
// Initialize the Dynamsoft Barcode Scanner
204
-
constBarcodescanner=newDynamsoft.BarcodeScanner({
181
+
constbarcodescanner=newDynamsoft.BarcodeScanner({
205
182
// Please don't forget to replace YOUR_LICENSE_KEY_HERE
206
183
license:"YOUR_LICENSE_KEY_HERE",
207
184
});
@@ -217,7 +194,6 @@ This is the **simplest** way to initialize the Barcode Scanner. The configuratio
217
194
constbarcodescanner=newDynamsoft.BarcodeScanner({
218
195
license:"YOUR_LICENSE_KEY_HERE",
219
196
scanMode:Dynamsoft.EnumScanMode.SM_MULTI_UNIQUE,
220
-
showResultView:true,
221
197
});
222
198
```
223
199
@@ -227,7 +203,10 @@ const barcodescanner = new Dynamsoft.BarcodeScanner({
227
203
(async () => {
228
204
// Launch the scanner and wait for the result
229
205
constresult=awaitbarcodescanner.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
+
}
231
210
})();
232
211
```
233
212
@@ -241,5 +220,5 @@ Now that the Barcode Scanner has been initialized and configured, it is ready to
241
220
Now that you've implemented the basic functionality, here are some recommended next steps to further explore the capabilities of the Barcode Scanner
242
221
243
222
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