Skip to content

Commit fc5d64f

Browse files
author
Amro Anwer
authored
Merge pull request #20 from Dynamsoft/amro-branch
Update README.md
2 parents c36197a + 8bb0e50 commit fc5d64f

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,74 @@ As mentioned previously, the purpose of this guide is to help you implement a He
2424

2525
The first step before you venture into writing the code is to include the SDK in your application. The simplest way to include the SDK would be to use the precompiled script - but you can also build it from source yourself.
2626

27+
### Using the Precompiled Script
28+
29+
The simplest way to include the SDK is to use either the [**jsDelivr**](https://jsdelivr.com/) or [**UNPKG**](https://unpkg.com/) CDN. The Hello World sample that this guide will explore uses **jsDelivr**:
30+
31+
- jsDelivr
32+
33+
```html
34+
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@2.0.0/dist/mrz-scanner.bundle.js"></script>
35+
```
36+
37+
- UNPKG
38+
39+
```html
40+
<script src="https://unpkg.com/dynamsoft-mrz-scanner@2.0.0/dist/mrz-scanner.bundle.js"></script>
41+
```
42+
43+
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**:
44+
45+
```sh
46+
npm i dynamsoft-mrz-scanner@2.0.0 -E
47+
# or
48+
yarn add dynamsoft-mrz-scanner@2.0.0 -E
49+
```
50+
51+
> [!WARNING]
52+
> When using a package manager like **npm** or **yarn**, you likely need to specify the location of the engine files as a link to a CDN. Please see the [MRZScannerConfig API]({{ site.api }}mrz-scanner.html#mrzscannerconfig) for a code snippet on how to set the *engineResourcePaths*.
53+
54+
Below is the complete Hello World sample page that uses the precompiled script served via a CDN.
55+
56+
```html
57+
<!DOCTYPE html>
58+
<html lang="en">
59+
<head>
60+
<meta charset="utf-8" />
61+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
62+
<title>Dynamsoft MRZ Scanner - Hello World</title>
63+
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@2.0.0/dist/mrz-scanner.bundle.js"></script>
64+
</head>
65+
66+
<body>
67+
<h1 style="font-size: large">Dynamsoft MRZ Scanner</h1>
68+
69+
<script>
70+
// Initialize the Dynamsoft MRZ Scanner
71+
const mrzScanner = new Dynamsoft.MRZScanner({
72+
license: "YOUR_LICENSE_KEY_HERE",
73+
});
74+
(async () => {
75+
// Launch the scanner and wait for the result
76+
const result = await mrzScanner.launch({});
77+
})();
78+
</script>
79+
</body>
80+
</html>
81+
```
82+
83+
> [!NOTE]
84+
>
85+
> This code is identical to the Hello World file mentioned in *Build from Source*, except for the script source.
86+
>
87+
> Please do not forget to replace `YOUR_LICENSE_KEY_HERE` with your own license key, whether it is trial or full.
88+
89+
To run the sample, create a new file called `hello-world.html`, then copy and paste the code above into the file. Next, serve the page directly by deploying it to a server.
90+
91+
If you are using VS Code, a quick and easy way to serve the project is using the [Five Server VSCode extension](https://marketplace.visualstudio.com/items?itemName=yandeu.five-server). Simply install the extension, open the `hello-world.html` file in the editor, and click "Go Live" in the bottom right corner of the editor. This will serve the application at `http://127.0.0.1:5500/hello-world.html`.
92+
93+
Alternatively, you can use other methods like `IIS` or `Apache` to serve the project, though we will omit those methods here for brevity.
94+
2795
### Building the Library from Source
2896

2997
In this guide, we will show the developer how to build the scanner themselves from the source files. The advantage of doing this is that it allows the developer to do some deep customization of the scanner if they are familiar with using the foundational products **Dynamsoft Label Recognizer**, **Dynamsoft Code Parser**, and the **Dynamsoft Camera Enhancer**.

0 commit comments

Comments
 (0)