-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathapp.component.ts
More file actions
36 lines (29 loc) · 1.29 KB
/
app.component.ts
File metadata and controls
36 lines (29 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { Component } from '@angular/core';
import { BarcodeScanner } from 'dynamsoft-barcode-reader-bundle';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrl: './app.component.css'
})
export class AppComponent {
title = 'angular';
async ngAfterViewInit(): Promise<void> {
// Configuration object for initializing the BarcodeScanner instance
const config = {
license: "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9", // Replace with your Dynamsoft license key
container: ".barcode-scanner-view", // Specify where to render the scanner UI
// Specify the path for the definition file "barcode-scanner.ui.xml" for the scanner view.
uiPath: "https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@10.5.3000/dist/",
// Specify custom paths for the engine resources
engineResourcePaths: {
rootDirectory: "https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@10.5.3000/dist/",
},
}
// Create an instance of the BarcodeScanner with the provided configuration
const barcodeScanner = new BarcodeScanner(config);
// Launch the scanner; once a barcode is detected, display its text in an alert
barcodeScanner.launch().then((result) => {
alert(result.barcodeResults[0].text);
});
}
}