Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ The simplest way to include the SDK is to use either the [**jsDelivr**](https://
- jsDelivr

```html
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@2.0.0/dist/mrz-scanner.bundle.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@2.1.0/dist/mrz-scanner.bundle.js"></script>
```

- UNPKG

```html
<script src="https://unpkg.com/dynamsoft-mrz-scanner@2.0.0/dist/mrz-scanner.bundle.js"></script>
<script src="https://unpkg.com/dynamsoft-mrz-scanner@2.1.0/dist/mrz-scanner.bundle.js"></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**:

```sh
npm i dynamsoft-mrz-scanner@2.0.0 -E
npm i dynamsoft-mrz-scanner@2.1.0 -E
# or
yarn add dynamsoft-mrz-scanner@2.0.0 -E
yarn add dynamsoft-mrz-scanner@2.1.0 -E
```

> [!WARNING]
Expand All @@ -60,7 +60,7 @@ Below is the complete Hello World sample page that uses the precompiled script s
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dynamsoft MRZ Scanner - Hello World</title>
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@2.0.0/dist/mrz-scanner.bundle.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@2.1.0/dist/mrz-scanner.bundle.js"></script>
</head>

<body>
Expand Down Expand Up @@ -139,7 +139,7 @@ Let's now go through the code of the Hello World sample and understand the purpo
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dynamsoft MRZ Scanner - Hello World</title>
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@2.0.0/dist/mrz-scanner.bundle.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@2.1.0/dist/mrz-scanner.bundle.js"></script>
</head>

<body>
Expand Down Expand Up @@ -212,6 +212,13 @@ Here is a quick breakdown of the UI elements that make up the result view

4. **Done Button**: Clicking this button basically closes the scanner and destroys the **MRZScanner** instance. At that point, the application will go back to the landing page, but the developer can dictate the action to take once this button is clicked. These actions can include allowing the user to perform some extra actions with the MRZ result, or navigating to another page, or really anything that the developer would like to do once the scanning operation is done.

>Note:
>
> In the Hello World sample, no action is taken once the Done button is clicked. The scanner closes and the user is met with an empty page. In order to open the scanner again, the user must refresh the page. However, this action can be changed according to the developer's wishes as indicated above.
> [!NOTE]
> In the Hello World sample, no action is taken once the Done button is clicked. The scanner closes and the user is met with an empty page. In order to open the scanner again, the user must refresh the page. You may choose to implement a more user-friendly behavior in a production environment, such as presenting the user with an option to re-open the MRZ Scanner upon closing it.


## Next Steps

Now that you got the most basic functionality of the MRZ Scanner up and running, it's time to explore the many ways in which the MRZ Scanner can be used, including customization and the ability to read directly from static images and PDFs. To learn more about those two topics, please visit the following articles

- [Customizing the MRZ Scanner](https://www.dynamsoft.com/mrz-scanner/docs/web/guides/mrz-scanner-customization.html)
- [Setting up the MRZ Scanner for Static Images and PDFs](https://www.dynamsoft.com/mrz-scanner/docs/web/guides/mrz-scanner-static-image.html)
8 changes: 8 additions & 0 deletions dev-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ app.get("/hello-world", (req, res) => {
res.sendFile(path.join(__dirname, "../samples/hello-world.html"));
});

app.get("/scenarios/use-file-input", (req, res) => {
res.sendFile(path.join(__dirname, "../samples/scenarios/use-file-input.html"));
});

let httpPort = 3002;
let httpsPort = 3003;

Expand Down Expand Up @@ -113,6 +117,8 @@ httpServer.listen(httpPort, () => {
console.log("\x1b[90m-------------------\x1b[0m");
console.log("\x1b[33m Hello World:\x1b[0m http://localhost:" + httpPort + "/hello-world");
console.log("\x1b[33m Demo:\x1b[0m http://localhost:" + httpPort + "/demo");
console.log("\x1b[90m-------------------\x1b[0m");
console.log("\x1b[33m Use File Input:\x1b[0m http://localhost:" + httpPort + "/scenarios/use-file-input");
});

httpsServer.listen(httpsPort, "0.0.0.0", () => {
Expand All @@ -132,6 +138,8 @@ httpsServer.listen(httpsPort, "0.0.0.0", () => {
ipv4Addresses.forEach((localIP) => {
console.log("\x1b[32m Hello World:\x1b[0m https://" + localIP + ":" + httpsPort + "/hello-world");
console.log("\x1b[32m Demo:\x1b[0m https://" + localIP + ":" + httpsPort + "/demo");
console.log("\x1b[90m-------------------\x1b[0m");
console.log("\x1b[32m Use File Input:\x1b[0m https://" + localIP + ":" + httpsPort + "/scenarios/use-file-input");
});
console.log("\n");
console.log("\x1b[90mPress Ctrl+C to stop the server\x1b[0m\n");
Expand Down
19 changes: 17 additions & 2 deletions dist/mrz-scanner.bundle.esm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,17 @@ declare enum EnumMRZData {
Age = "age",
Sex = "sex",
IssuingState = "issuingState",
IssuingStateRaw = "issuingStateRaw",
Nationality = "nationality",
NationalityRaw = "nationalityRaw",
DateOfBirth = "dateOfBirth",
DateOfExpiry = "dateOfExpiry"
}
interface MRZResult {
status: ResultStatus;
originalImageResult?: DSImageData;
data?: MRZData;
imageData?: boolean;
_imageData?: DSImageData;
}
interface MRZData {
Expand All @@ -87,7 +90,9 @@ interface MRZData {
[EnumMRZData.Age]: number;
[EnumMRZData.Sex]: string;
[EnumMRZData.IssuingState]: string;
[EnumMRZData.IssuingStateRaw]: string;
[EnumMRZData.Nationality]: string;
[EnumMRZData.NationalityRaw]: string;
[EnumMRZData.DateOfBirth]: MRZDate;
[EnumMRZData.DateOfExpiry]: MRZDate;
}
Expand All @@ -109,7 +114,10 @@ interface MRZScannerViewConfig {
showUploadImage?: boolean;
showFormatSelector?: boolean;
showSoundToggle?: boolean;
showPoweredByDynamsoft?: boolean;
enableMultiFrameCrossFilter?: boolean;
uploadAcceptedTypes?: string;
uploadFileConverter?: (file: File) => Promise<Blob>;
}
declare class MRZScannerView {
private resources;
Expand Down Expand Up @@ -137,7 +145,8 @@ declare class MRZScannerView {
private attachOptionClickListeners;
private highlightCameraAndResolutionOption;
private toggleSelectCameraBox;
private uploadImage;
private relaunch;
private uploadFile;
private toggleSoundFeedback;
private calculateScanRegion;
private toggleScanGuide;
Expand Down Expand Up @@ -229,7 +238,13 @@ declare class MRZScanner {
private initializeMRZScannerConfig;
private createViewContainers;
dispose(): void;
launch(): Promise<MRZResult>;
/**
* Processes an uploaded image file
* @param imageOrFile The file to process
* @returns Promise with the document result
*/
private processUploadedFile;
launch(imageOrFile: Blob | string | DSImageData | HTMLImageElement | HTMLVideoElement | HTMLCanvasElement): Promise<MRZResult>;
}

declare const DynamsoftMRZScanner: {
Expand Down
2 changes: 1 addition & 1 deletion dist/mrz-scanner.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mrz-scanner.bundle.mjs

Large diffs are not rendered by default.

19 changes: 17 additions & 2 deletions dist/mrz-scanner.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,17 @@ declare enum EnumMRZData {
Age = "age",
Sex = "sex",
IssuingState = "issuingState",
IssuingStateRaw = "issuingStateRaw",
Nationality = "nationality",
NationalityRaw = "nationalityRaw",
DateOfBirth = "dateOfBirth",
DateOfExpiry = "dateOfExpiry"
}
interface MRZResult {
status: ResultStatus;
originalImageResult?: DSImageData;
data?: MRZData;
imageData?: boolean;
_imageData?: DSImageData;
}
interface MRZData {
Expand All @@ -94,7 +97,9 @@ interface MRZData {
[EnumMRZData.Age]: number;
[EnumMRZData.Sex]: string;
[EnumMRZData.IssuingState]: string;
[EnumMRZData.IssuingStateRaw]: string;
[EnumMRZData.Nationality]: string;
[EnumMRZData.NationalityRaw]: string;
[EnumMRZData.DateOfBirth]: MRZDate;
[EnumMRZData.DateOfExpiry]: MRZDate;
}
Expand All @@ -116,7 +121,10 @@ interface MRZScannerViewConfig {
showUploadImage?: boolean;
showFormatSelector?: boolean;
showSoundToggle?: boolean;
showPoweredByDynamsoft?: boolean;
enableMultiFrameCrossFilter?: boolean;
uploadAcceptedTypes?: string;
uploadFileConverter?: (file: File) => Promise<Blob>;
}
declare class MRZScannerView {
private resources;
Expand Down Expand Up @@ -144,7 +152,8 @@ declare class MRZScannerView {
private attachOptionClickListeners;
private highlightCameraAndResolutionOption;
private toggleSelectCameraBox;
private uploadImage;
private relaunch;
private uploadFile;
private toggleSoundFeedback;
private calculateScanRegion;
private toggleScanGuide;
Expand Down Expand Up @@ -236,7 +245,13 @@ declare class MRZScanner {
private initializeMRZScannerConfig;
private createViewContainers;
dispose(): void;
launch(): Promise<MRZResult>;
/**
* Processes an uploaded image file
* @param imageOrFile The file to process
* @returns Promise with the document result
*/
private processUploadedFile;
launch(imageOrFile: Blob | string | DSImageData | HTMLImageElement | HTMLVideoElement | HTMLCanvasElement): Promise<MRZResult>;
}

declare const DynamsoftMRZScanner: {
Expand Down
2 changes: 1 addition & 1 deletion dist/mrz-scanner.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mrz-scanner.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mrz-scanner.no-content-bundle.esm.js

Large diffs are not rendered by default.

Loading