From 72ee459422a23f79d9f0dd13438912cc61cdcd39 Mon Sep 17 00:00:00 2001 From: DMGithubPublisher Date: Thu, 10 Oct 2024 15:51:50 +0800 Subject: [PATCH] update to internal commit 7dd25876 --- _config.yml | 3 +- ...lt-layout.html => default-layout-OLD.html} | 0 ...{search-page.html => search-page-OLD.html} | 0 .../api-reference/code-parser-v2.2.10.md | 150 +++++++++ .../javascript/api-reference/code-parser.md | 2 +- .../javascript/user-guide/index-2.2.10.md | 302 ++++++++++++++++++ programming/javascript/user-guide/index.md | 50 ++- search.md | 1 + 8 files changed, 475 insertions(+), 33 deletions(-) rename _layouts/{default-layout.html => default-layout-OLD.html} (100%) rename _layouts/{search-page.html => search-page-OLD.html} (100%) create mode 100644 programming/javascript/api-reference/code-parser-v2.2.10.md create mode 100644 programming/javascript/user-guide/index-2.2.10.md diff --git a/_config.yml b/_config.yml index eb4ba1a..ce02b36 100644 --- a/_config.yml +++ b/_config.yml @@ -27,7 +27,8 @@ dnt_icon: /code-parser/docs/web/assets/img-icon/icon-dnt.svg release_notes: /code-parser/docs/core/release-notes/ code_types: /code-parser/docs/core/code-types/ -useVersionTree: true +useVersionTree: false +isDCV: true baseurl: "/code-parser/docs/web" plugins: diff --git a/_layouts/default-layout.html b/_layouts/default-layout-OLD.html similarity index 100% rename from _layouts/default-layout.html rename to _layouts/default-layout-OLD.html diff --git a/_layouts/search-page.html b/_layouts/search-page-OLD.html similarity index 100% rename from _layouts/search-page.html rename to _layouts/search-page-OLD.html diff --git a/programming/javascript/api-reference/code-parser-v2.2.10.md b/programming/javascript/api-reference/code-parser-v2.2.10.md new file mode 100644 index 0000000..1e90efd --- /dev/null +++ b/programming/javascript/api-reference/code-parser-v2.2.10.md @@ -0,0 +1,150 @@ +--- +layout: default-layout +title: CodeParser Class - Dynamsoft Code Parser SDK JS Edition API Reference +description: This page shows CodeParser Class of Dynamsoft Code Parser SDK JS Edition. +keywords: CodeParser, api reference, JS, JavaScript +needAutoGenerateSidebar: true +--- + +# CodeParser Class + +The `CodeParser` class enable users to parse given bytes or a string to be human-readable. + +| Method | Description | +| -------------------------------------------- | ---------------------------------------------------------------------- | +| `static` [createInstance()](#createinstance) | Initializes a new instance of the `CodeParser` class. | +| [dispose()](#dispose) | Releases all resources used by the `CodeParser` object. | +| [disposed](#disposed) | Returns whether the `CodeParser` object has been disposed of. | +| [initSettings](#initsettings) | Initializes runtime settings with the settings in a given JSON string. | +| [resetSettings](#resetsettings) | Resets runtime settings to default. | +| [parse](#parse) | Parses code data for readable results. | + +## createInstance + +Initializes a new instance of the `CodeParser` class. + +**Syntax** + +```typescript +createInstance(): Promise; +``` + +**Parameter** + +None. + +**Return value** + +A promise that resolves to the initialized `CodeParser` object. + +**Code snippet** + +```javascript +let parser = await Dynamsoft.DCP.CodeParser.createInstance(); +``` + +## dispose + +Releases all resources used by the `CodeParser` object. + +**Syntax** + +```typescript +dispose(): Promise; +``` + +**Parameter** + +None. + +**Return value** + +Returns a promise that resolves when the resources have been successfully released. + +**Code snippet** + +```javascript +let parser = await Dynamsoft.DCP.CodeParser.createInstance(); +// Use the parser to perform a job. +// ... +// Release the resources after the job is finished. +parser.dispose(); +``` + +## disposed + +Returns whether the `CodeParser` object has been disposed of. + +**Syntax** + +```typescript +disposed: boolean; +``` + +**Parameter** + +None. + +**Return value** + +A boolean value that indicates whether the `CodeParser` object has been disposed of. + +**Code snippet** + +```javascript +if(parser.disposed){ + console.log("The parser has been disposed of."); +} else { + // Use the parser to perform a job. +} +``` + +## initSettings + +Initializes settings from a given string. + +```typescript +initSettings: (settings: string) => Promise; +``` + +**Parameters** + +* `settings`: A JSON string that represents the content of the settings. + +**Return value** + +A promise that resolves when the operation has completed. It does not provide any value upon resolution. + +## resetSettings + +Resets all parameters to default values. + +```typescript +resetSettings: () => Promise; +``` + +**Parameters** + +None. + +**Return value** + +Returns a promise that resolves when the settings have been successfully reset to their default values. + +## parse + +Parses a single string to be human-readable. + +```typescript +parse: (source: Uint8Array | string, taskSettingName?: string) => Promise; +``` + +**Parameters** + +* `source`: the array of bytes or the string to parse. + +* `taskSettingName`: the name of [CodeParserTaskSetting](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/code-parser-task-settings/) that defines the settings used for code parsing. + +**Return Value** + +Returns an array of [ParsedResultItem](./interfaces/parsed-result-item.md) containing the human-readable results. diff --git a/programming/javascript/api-reference/code-parser.md b/programming/javascript/api-reference/code-parser.md index 1e90efd..008c24e 100644 --- a/programming/javascript/api-reference/code-parser.md +++ b/programming/javascript/api-reference/code-parser.md @@ -136,7 +136,7 @@ Returns a promise that resolves when the settings have been successfully reset t Parses a single string to be human-readable. ```typescript -parse: (source: Uint8Array | string, taskSettingName?: string) => Promise; +parse: (source: Uint8Array | string | Array, taskSettingName?: string) => Promise; ``` **Parameters** diff --git a/programming/javascript/user-guide/index-2.2.10.md b/programming/javascript/user-guide/index-2.2.10.md new file mode 100644 index 0000000..6ce7833 --- /dev/null +++ b/programming/javascript/user-guide/index-2.2.10.md @@ -0,0 +1,302 @@ +--- +layout: default-layout +title: User Guide - Dynamsoft Code Parser for JavaScript v2.x +description: This is the user guide page of Dynamsoft Code Parser for JavaScript SDK v2.x. +keywords: user guide, javascript +breadcrumbText: User Guide +noTitleIndex: true +needAutoGenerateSidebar: true +needGenerateH3Content: true +--- + + + +# Dynamsoft Code Parser for Your Website + +Dynamsoft Code Parser is designed to parse data strings (usually encrypted in barcodes, machine readable zones, etc.) into human-readable information. The JavaScript edition is based on WebAssembly and offers great speed and accuracy. With its well-designed API, you can equip your web pages with a code parser with just a few lines of code. + +In this guide, you will learn step by step on how to integrate the SDK into your website. + +Table of Contents + +- [Dynamsoft Code Parser for Your Website](#dynamsoft-code-parser-for-your-website) + - [Hello World](#hello-world) + - [About the code](#about-the-code) + - [Run the example](#run-the-example) + - [Building your own page](#building-your-own-page) + - [Include the SDK](#include-the-sdk) + - [Use a CDN](#use-a-cdn) + - [Host the SDK yourself](#host-the-sdk-yourself) + - [Configure the SDK](#configure-the-sdk) + - [Specify the license](#specify-the-license) + - [Specify the location of the "engine" files (optional)](#specify-the-location-of-the-engine-files-optional) + - [Interact with the SDK](#interact-with-the-sdk) + - [Load the specification for parsing](#load-the-specification-for-parsing) + - [Create a `CodeParser` object](#create-a-codeparser-object) + - [Start Parsing](#start-parsing) + - [System requirements](#system-requirements) + - [Release notes](#release-notes) + - [API Documentation](#api-documentation) + +## Hello World + +Dynamsoft Code Parser is designed to work both independently and alongside another functional product such as [Dynamsoft Barcode Reader](https://www.dynamsoft.com/barcode-reader/overview/) or [Dynamsoft Label Recognizer](https://www.dynamsoft.com/label-recognition/overview/). + +Let's start with the "Hello World" example of the SDK which demonstrates how to use the minimum code to enable a web page to parse an existing string into human-readable fields. + +The complete code of the "Hello World" example is shown below: + +```html + + + + + + + + + +
+ + + + +``` + +### About the code + +- `let passportMRZStr = "P NOTE: +> +> The sample code requires the following to run: +> +> 1. Internet connection +> 2. [A supported browser](#system-requirements) + +Please note: + +- Although the page should work properly when opened directly as a file ("file:///"), it's recommended that you deploy it to a web server and access it via HTTPS. +- On first use, you need to wait a few seconds for the SDK to initialize. +- The license "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" used in this sample is an online license good for 24 hours and requires network connection to work. To test the SDK further, you can request a 30-day trial license via the Request a Trial License link. + +If the test doesn't go as expected, you can [contact us](https://www.dynamsoft.com/company/customer-service/#contact). + +## Building your own page + +### Include the SDK + +#### Use a CDN + +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" example above uses **jsDelivr**. + +* jsDelivr + + ```html + + + + ``` + +* UNPKG + + ```html + + + + ``` + +#### Host the SDK yourself + +Besides using the CDN, you can also download the SDK and host its files on your own website / server before including it in your application. + +Options to download the SDK: + +- From the website + + Sign in the [Customer Portal](https://www.dynamsoft.com/customer/index?utm_source=docs&product=dcp) and Download the JavaScript ZIP package + +* yarn + + ```cmd + yarn add dynamsoft-core@3.2.10 --save + yarn add dynamsoft-license@3.2.10 --save + yarn add dynamsoft-code-parser@2.2.10 --save + ``` + +* npm + + ```cmd + npm install dynamsoft-core@3.2.10 --save + npm install dynamsoft-license@3.2.10 --save + npm install dynamsoft-code-parser@2.2.10 --save + ``` + +Depending on how you downloaded the SDK and where you put it, you can typically include it like this: + +```html + + + + +``` + +or + +```html + + + +``` + +or + +```typescript +import { LicenseManager } from "dynamsoft-license"; +import { type ParsedResultItem, CodeParser } from 'dynamsoft-code-parser'; +``` + +### Configure the SDK + +Before using the SDK, you need to configure a few things. + +#### Specify the license + +The SDK requires a license to work, use the method `Dynamsoft.License.LicenseManager.initLicense` to specify the license key. + +```javascript +//You can visit https://www.dynamsoft.com/customer/license/trialLicense?utm_source=github&product=dcp&package=js to get your own trial license good for 30 days. +Dynamsoft.License.LicenseManager.initLicense("YOUR-LICENSE-KEY"); +``` + +#### Specify the location of the "engine" files (optional) + +This is usually only required with frameworks like Angular or React, etc. where the referenced JavaScript files such as `core.js`, `dcp.js` are compiled into another file. + +The purpose is to tell the SDK where to find the engine files (\*.worker.js, \*.wasm.js and \*.wasm, etc.). The API is called `Dynamsoft.Core.CoreModule.engineResourcePaths`: + +```javascript +//The following code uses the jsDelivr CDN, feel free to change it to your own location of these files +Dynamsoft.Core.CoreModule.engineResourcePaths.core = "https://cdn.jsdelivr.net/npm/dynamsoft-core@3.2.10/dist/"; +Dynamsoft.Core.CoreModule.engineResourcePaths.license = "https://cdn.jsdelivr.net/npm/dynamsoft-license@3.2.10/dist/"; +Dynamsoft.Core.CoreModule.engineResourcePaths.dcp = "https://cdn.jsdelivr.net/npm/dynamsoft-code-parser@2.2.10/dist/"; +``` + +### Interact with the SDK + +#### Load the specification for parsing + +The SDK requires the specification of the code string to parse it. If we are going to parse the MRZ strings found on passports, we need the specification "MRTD\_TD3\_PASSPORT". + +```javascript +await Dynamsoft.DCP.CodeParserModule.loadSpec("MRTD_TD3_PASSPORT"); +``` + +#### Create a `CodeParser` object + +Then we create a `CodeParser` object. + +```javascript +let parser = null; +try { + parser = await Dynamsoft.DCP.CodeParser.createInstance(); +} catch (ex) { + console.error(ex); +} +``` + +Tip: When creating a `CodeParser` object within a function which may be called more than once, it's best to use a "helper" variable to avoid double creation such as `helperParser` in the following code + +```javascript +let helperParser = null; + +function foo() { + try { + const parser = await (helperParser = helperParser || Dynamsoft.DCP.CodeParser.createInstance()); + } catch (ex) { + console.error(ex); + } +} +``` + +#### Start Parsing + +The method `parse()` takes data in two formats: `Uint8Array` and `string`. `Uint8Array` refers to the binary data produced by another software such as Dynamsoft Barcode Reader. + +```javascript +let parsedResultItem = await parser.parse("THE-CODE-TO-PARSE"); +``` + +## System requirements + +The SDK requires the following features to work: + +- Secure context (HTTPS deployment) + + When deploying your application / website for production, make sure to serve it via a secure HTTPS connection. This is required because Dynamsoft License requires a secure context to work. + +- `WebAssembly`, `Blob`, `URL`/`createObjectURL`, `Web Workers` + + The above four features are required for the SDK to work. + +The following table is a list of supported browsers based on the above requirements: + + | Browser Name | Version | + | :----------: | :-----: | + | Chrome | v78+ | + | Firefox | v62+ | + | Safari | v14+ | + | Edge | v79+ | + +Apart from the browsers, the operating systems may impose some limitations of their own that could restrict the use of the SDK. + +## Release notes + +Learn what are included in each release at [Dynamsoft Code Parser JavaScript Edition Release Notes](https://www.dynamsoft.com/code-parser/docs/web/programming/javascript/release-notes/?ver=latest). + +## API Documentation + +For more information about the APIs of the SDK, read [Dynamsoft Code Parser JavaScript Edition API Reference](https://www.dynamsoft.com/code-parser/docs/web/programming/javascript/api-reference/?ver=2.0.20). diff --git a/programming/javascript/user-guide/index.md b/programming/javascript/user-guide/index.md index 6ce7833..b6aa590 100644 --- a/programming/javascript/user-guide/index.md +++ b/programming/javascript/user-guide/index.md @@ -51,9 +51,9 @@ The complete code of the "Hello World" example is shown below: - - - + + +
- - + + + ``` * UNPKG ```html - - - + + + ``` #### Host the SDK yourself @@ -155,33 +155,21 @@ Besides using the CDN, you can also download the SDK and host its files on your Options to download the SDK: -- From the website - - Sign in the [Customer Portal](https://www.dynamsoft.com/customer/index?utm_source=docs&product=dcp) and Download the JavaScript ZIP package - -* yarn - - ```cmd - yarn add dynamsoft-core@3.2.10 --save - yarn add dynamsoft-license@3.2.10 --save - yarn add dynamsoft-code-parser@2.2.10 --save - ``` - * npm ```cmd - npm install dynamsoft-core@3.2.10 --save - npm install dynamsoft-license@3.2.10 --save - npm install dynamsoft-code-parser@2.2.10 --save + npm install dynamsoft-core@3.4.20 --save + npm install dynamsoft-license@3.4.20 --save + npm install dynamsoft-code-parser@2.4.22 --save ``` Depending on how you downloaded the SDK and where you put it, you can typically include it like this: ```html - - - + + + ``` or @@ -220,9 +208,9 @@ The purpose is to tell the SDK where to find the engine files (\*.worker.js, \*. ```javascript //The following code uses the jsDelivr CDN, feel free to change it to your own location of these files -Dynamsoft.Core.CoreModule.engineResourcePaths.core = "https://cdn.jsdelivr.net/npm/dynamsoft-core@3.2.10/dist/"; -Dynamsoft.Core.CoreModule.engineResourcePaths.license = "https://cdn.jsdelivr.net/npm/dynamsoft-license@3.2.10/dist/"; -Dynamsoft.Core.CoreModule.engineResourcePaths.dcp = "https://cdn.jsdelivr.net/npm/dynamsoft-code-parser@2.2.10/dist/"; +Dynamsoft.Core.CoreModule.engineResourcePaths.core = "https://cdn.jsdelivr.net/npm/dynamsoft-core@3.4.20/dist/"; +Dynamsoft.Core.CoreModule.engineResourcePaths.license = "https://cdn.jsdelivr.net/npm/dynamsoft-license@3.4.20/dist/"; +Dynamsoft.Core.CoreModule.engineResourcePaths.dcp = "https://cdn.jsdelivr.net/npm/dynamsoft-code-parser@2.4.22/dist/"; ``` ### Interact with the SDK @@ -287,7 +275,7 @@ The following table is a list of supported browsers based on the above requireme | Browser Name | Version | | :----------: | :-----: | | Chrome | v78+ | - | Firefox | v62+ | + | Firefox | v68+ | | Safari | v14+ | | Edge | v79+ | diff --git a/search.md b/search.md index 95c3fe3..0a32377 100644 --- a/search.md +++ b/search.md @@ -2,4 +2,5 @@ layout: search-page title: Dynamsoft Code Parser SDK Documentation Search keywords: Dynamsoft Code Parser SDK Documentation Search +cx: 53a201f66061dfc84 --- \ No newline at end of file