diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6256f13..1d78615 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,9 +5,9 @@ name: CI # Controls when the workflow will run on: # Triggers the workflow on push events but only for the main branch - push: - branches: - # - main + push: + branches: + - main - preview # Allows you to run this workflow manually from the Actions tab @@ -52,8 +52,8 @@ jobs: username: ${{ secrets.FTP_DYNAMSOFT_LOCAL_USER }} password: ${{ secrets.FTP_DYNAMSOFT_LOCAL_PASSWORD }} port: 21 - local-dir: /home/ubuntu/DDNDocServer/_site/ - server-dir: /www.dynamsoft.com/code-parser/docs/js/ + local-dir: /home/ubuntu/DCPDocJS/_site/ + server-dir: /www.dynamsoft.com/code-parser/docs/web/ Build-Preview: if: ${{ github.ref == 'refs/heads/preview' }} @@ -91,4 +91,4 @@ jobs: password: ${{ secrets.FTP_TEST_SITE_PASSWORD }} port: 7500 local-dir: /home/ubuntu/DCPDocJSPreview/_site/ - server-dir: /www.dynamsoft.com/code-parser/docs/js/ + server-dir: /www.dynamsoft.com/code-parser/docs/web/ diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..1529ff2 --- /dev/null +++ b/_config.yml @@ -0,0 +1,48 @@ +repositoryUrl: https://github.com/dynamsoft-docs/code-parser-docs-js/blob/main +repository: dynamsoft-docs/code-parser-docs-js +docFullPath: https://www.dynamsoft.com/code-parser/docs/web +firstLevelUrl: /code-parser/docs/web/ +docHomePage: /code-parser/docs/core/introduction/ + +javascript: /code-parser/docs/web/programming/javascript/ +javascript-api: /code-parser/docs/web/programming/javascript/api-reference/ +javascript-api-enum: /code-parser/docs/web/programming/javascript/api-reference/enum/ +javascript-api-interface: /code-parser/docs/web/programming/javascript/api-reference/interface/ +javascript-release-notes: /code-parser/docs/web/programming/javascript/release-notes/ + +assets: /code-parser/docs/web/assets/ +edit_icon: /code-parser/docs/web/assets/img-icon/edit-icon.png +smile_icon: /code-parser/docs/web/assets/img-icon/icon-smile.png +sad_icon: /code-parser/docs/web/assets/img-icon/icon-sad.png +dbr_icon: /code-parser/docs/web/assets/img-icon/icon-dbr.svg +dwt_icon: /code-parser/docs/web/assets/img-icon/icon-dwt.svg +dnt_icon: /code-parser/docs/web/assets/img-icon/icon-dnt.svg + +release-notes: /code-parser/docs/core/release-notes/ + +useVersionTree: true + +baseurl: "/code-parser/docs/web" +plugins: + - jemoji + +defaults: + - scope: + path: "" + values: + layout: "default-layout" + noTitleIndex: true + needAutoGenerateSidebar: true + needGenerateH3Content: true + - scope: + path: "programming/javascript" + values: + docRootName: "Code Parser JS Edition" + docHomePage: "/code-parser/docs/web/programming/javascript/" + - scope: + path: "Hide_Tree_Page.html" + values: + sitemap: false + +url: "https://www.dynamsoft.com" # sitemap root + diff --git a/_data/full_tree.yml b/_data/full_tree.yml new file mode 100644 index 0000000..391bdaf --- /dev/null +++ b/_data/full_tree.yml @@ -0,0 +1,3 @@ +tree_file_list: + - sidelist-full-tree.html + - sidelist-programming-javascript.html diff --git a/_data/product_version.yml b/_data/product_version.yml new file mode 100644 index 0000000..4843c0d --- /dev/null +++ b/_data/product_version.yml @@ -0,0 +1,2 @@ +version_info_list: + - latest version diff --git a/_includes/dcpNav.html b/_includes/dcpNav.html new file mode 100644 index 0000000..f9f9789 --- /dev/null +++ b/_includes/dcpNav.html @@ -0,0 +1,77 @@ + + +
+
+
+
+ +
+
+
+
+
+ +
Resource Base
+
+
+
+
+
+ +
+
+
+
\ No newline at end of file diff --git a/_includes/sidelist-full-tree.html b/_includes/sidelist-full-tree.html new file mode 100644 index 0000000..5ddeaf6 --- /dev/null +++ b/_includes/sidelist-full-tree.html @@ -0,0 +1 @@ +{%- include liquid_searchVersionTreeFile.html ver=include.ver curPath=include.curPath targetRelativePath="sidelist-programming-javascript.html" -%} diff --git a/_includes/sidelist-programming-javascript.html b/_includes/sidelist-programming-javascript.html new file mode 100644 index 0000000..598386e --- /dev/null +++ b/_includes/sidelist-programming-javascript.html @@ -0,0 +1,30 @@ +
  • DEVELOPMENT
  • +
  • User Guide +
  • +
  • API Reference + +
  • +
  • Release Notes + +
  • + diff --git a/_layouts/default-layout.html b/_layouts/default-layout.html new file mode 100644 index 0000000..601e0d7 --- /dev/null +++ b/_layouts/default-layout.html @@ -0,0 +1,106 @@ + + + +{%- include head.html -%} + + +
    + {%- include page_header.html -%} +
    + {%- include dcpNav.html -%} +
    Table of contents
    +
    +
    + +
    +
    + {%- include main-page-head.html -%} +
    +
    +
    + {{ content }} +
    +
    +
    +

    This page is compatible for:

    +

    Version 1.0

    +
    +
    +

    Is this page helpful?

    + YesYes + NoNo +
    +
    + {%- if page.needAutoGenerateSidebar -%} +

    In this article:

    +
    + {%- endif -%} +
    +
    + +
    +
    +
    +
    +
    +
    + {%- include liquid_autoGenerateHistoryList.html -%} + {%- include auto-version-list.html -%} +
    +
    +
    +
    + {%- include page_footer.html -%} +
    + + + + + + + + + + {%- include livehelp.html -%} + + + + + + + + + + + diff --git a/_layouts/home-page.html b/_layouts/home-page.html new file mode 100644 index 0000000..a3a268e --- /dev/null +++ b/_layouts/home-page.html @@ -0,0 +1,50 @@ + + + +{%- include head.html -%} + + + + +
    + {%- include page_header.html -%} +
    +
    +
    +
    + + {{ content }} +
    +
    +
    +
    + {%- include page_footer.html -%} +
    + + + + + + + diff --git a/_layouts/search-page.html b/_layouts/search-page.html new file mode 100644 index 0000000..c625344 --- /dev/null +++ b/_layouts/search-page.html @@ -0,0 +1,319 @@ + + + +{%- include head.html -%} + + + +
    + {%- include page_header.html -%} +
    +
    +
    +
    + +
    +
    +
    +
    + +
    Documentation
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    Table of contents
    +
    +
    +
    +
    +
    +
    +
    +

    Search

    + + +
    +
    +
    + +
    +
    +
    +
    +
    + {%- include page_footer.html -%} +
    + + + + + {%- if page.needAutoGenerateSidebar -%} + {%- unless page.needGenerateH3Content -%} + + {%- else -%} + + {%- endunless -%} + {%- else -%} + + {%- endif -%} + + + + {%- include livehelp.html -%} + + + \ No newline at end of file diff --git a/programming/javascript/api-reference/CodeParser.md b/programming/javascript/api-reference/CodeParser.md new file mode 100644 index 0000000..3f91e0c --- /dev/null +++ b/programming/javascript/api-reference/CodeParser.md @@ -0,0 +1,193 @@ +--- +layout: default-layout +title: CodeParser - Dynamsoft Code Parser JavaScript API +description: This is the CodeParser Class of Dynamsoft Code Parser JavaScript SDK. +keywords: CodeParser, api reference, javascript, js +needAutoGenerateSidebar: true +needGenerateH3Content: true +noTitleIndex: true +breadcrumbText: CodeParser +--- + +# CodeParser + +A CodeParser takes code data in forms of byte array or plain string as input and returns parsed results. The following code snippet shows its basic usage: + +```js +let parser = await Dynamsoft.DCP.CodeParser.createInstance(); +parser.setCodeFormat(enumcodeformat); +let result = await parser.parseData(code); +console.log(result); +``` + +## API Index + +### Create and Destroy + +| API Name | Description | +|---|---| +| [createInstance()](#createinstance) | Creates a `CodeParser` instance. | +| [destroyContext()](#destroycontext) | Destroys the `CodeParser` instance in WASM. | + +### Set Code Format + +| API Name | Description | +|---|---| +| [setCodeFormat()](#setcodeformat) | Sets input code's format. | + +### Parse Code Data + +| API Name | Description | +|---|---| +| [parseData()](#parsedata) | Parses code data for readable results. | + + + + +## createInstance + +Creates a `CodeParser` instance. + +```typescript +static createInstance(): Promise +``` + +### Return Value + +A promise resolving to the created `CodeParser` object. + +### Code Snippet + +```js +let reader = await Dynamsoft.DCP.CodeParser.createInstance(); +``` + +## destroyContext + +Destroys the `CodeParser` instance in WASM. If your page needs to create new instances from time to time, don't forget to destroy unused old instances. + +```typescript +destroyContext(): void +``` + +### Code Snippet + +```js +let parser = await Dynamsoft.DCP.CodeParser.createInstance(); +// ... parse ... +parser.destroyContext(); +``` + +## setCodeFormat + +Sets the code format that needs parsing. See EnumCodeFormat to check if it has the code format you are looking for. + +```typescript +setCodeFormat(format: EnumCodeFormat): Promise +``` + +### Parameters + +`format`: specifies the code's format represented by EnumCodeFormat. + +### Return Value + +A promise that resolves when the operation succeeds. + +### Code Snippet + +```js +await parser.setCodeFormat(Dynamsoft.DCP.EnumCodeFormat.CF_AUTO); +// ... parse ... +``` + +## parseData + +Parses the code into readable info. + +```typescript +parseData(source: number[] | Uint8Array | string): Promise +``` + +### Parameters + +`source`: specifies the code data represented by a numder[], Uint8Array or string. + +### Return Value + +A promise resolving to a `ParseResult` object which contains the parsing result. + +### Code Snippet + +```js +await parser.parseData(YOUR-CODE-THAT-NEEDS-PARSING); +``` + +### See Also + +* [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) +* [ParseResult](./interface/ParseResult.md) + + \ No newline at end of file diff --git a/programming/javascript/api-reference/InitializeEngine.md b/programming/javascript/api-reference/InitializeEngine.md new file mode 100644 index 0000000..5cb6b6a --- /dev/null +++ b/programming/javascript/api-reference/InitializeEngine.md @@ -0,0 +1,48 @@ +--- +layout: default-layout +title: Initialize Engine - Dynamsoft Code Parser JavaScript API +description: This page shows the APIs used to initialize engine in Dynamsoft Code Parser JavaScript SDK. +keywords: Initialize Engine, api reference, javascript, js +needAutoGenerateSidebar: true +needGenerateH3Content: true +noTitleIndex: true +breadcrumbText: Initialize Engine +--- + +# Initialization + +* engineResourcePath +* loadWasm() + +## engineResourcePath + +Specifies the path to find the engine(s). The property needs to be set before [loadWasm](#loadwasm). If not specified, the library will try to find the engine in the same location as the main JavaScript file (dcp.js). + +```typescript +static engineResourcePath: string +``` + +**Code Snippet** + +```js +Dynamsoft.DCP.CodeParser.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-code-parser@1.1.0/dist/"; +await Dynamsoft.DCP.CodeParser.loadWasm(); +``` + +## loadWasm + +Downloads and compiles the engine to get it loaded/ready for a CodeParser instance to be created. You can call this API to silently set the operating environment of the library as soon as the page is loaded, avoiding unnecessary waiting time when using the library later. + +If this API is not called beforehand, it will be called automatically when creating an instance of CodeParser. + +```typescript +static loadWasm(): Promise +``` + +**Code Snippet** + +```js +window.addEventListener('DOMContentLoaded', (event) => { + Dynamsoft.DCP.CodeParser.loadWasm(); +}); +``` diff --git a/programming/javascript/api-reference/InterfacesEnums.md b/programming/javascript/api-reference/InterfacesEnums.md new file mode 100644 index 0000000..90188b8 --- /dev/null +++ b/programming/javascript/api-reference/InterfacesEnums.md @@ -0,0 +1,27 @@ +--- +layout: default-layout +title: Interfaces and Enums - Dynamsoft Code Parser JavaScript API +description: This page shows the interfaces and enums of Dynamsoft Code Parser JavaScript SDK. +keywords: CodeParser, api reference, javascript, js +needAutoGenerateSidebar: true +needGenerateH3Content: true +noTitleIndex: true +breadcrumbText: CodeParser +--- + +# Interfaces and Enums + +In order to make the code more predictable and readable, the library defines a series of supporting interfaces and enumerations. + +## Interfaces + +* [CodeParserException](./interface/CodeParserException.md) +* [BasicPersonalInfo](./interface/BasicPersonalInfo.md) +* [ParseResult](./interface/ParseResult.md) + +## Enums + +* [EnumErrorCode](./enum/EnumErrorCode.md) +* [EnumCodeFormat](./enum/EnumCodeFormat.md) +* [EnumResultInfoType](./enum/EnumResultInfoType.md) + diff --git a/programming/javascript/api-reference/LicenseControl.md b/programming/javascript/api-reference/LicenseControl.md new file mode 100644 index 0000000..149e255 --- /dev/null +++ b/programming/javascript/api-reference/LicenseControl.md @@ -0,0 +1,32 @@ +--- +layout: default-layout +title: Initialize License - Dynamsoft Code Parser JavaScript API +description: This page shows the APIs used to initialize license in Dynamsoft Code Parser JavaScript SDK. +keywords: Initialize License, api reference, javascript, js +needAutoGenerateSidebar: true +needGenerateH3Content: true +noTitleIndex: true +breadcrumbText: Initialize License +--- + +# License Control + +* license + + +## license + +Specify an online license or an offline license. Dynamsoft usually provides an online license. + +`license` needs to be set before `createInstance()` or `loadWasm()`. + +```typescript +static license: string +``` + +**Code Snippet** + +```js +Dynamsoft.DCP.CodeParser.license = "YOUR-LICENSE-KEY"; +let parser = await Dynamsoft.DCP.CodeParser.createInstance(); +``` \ No newline at end of file diff --git a/programming/javascript/api-reference/enum/EnumCodeFormat.md b/programming/javascript/api-reference/enum/EnumCodeFormat.md new file mode 100644 index 0000000..8c91a36 --- /dev/null +++ b/programming/javascript/api-reference/enum/EnumCodeFormat.md @@ -0,0 +1,21 @@ +--- +layout: default-layout +title: EnumCodeFormat - Dynamsoft Code Parser JavaScript Enum +description: This page shows the EnumCodeFormat enum of Dynamsoft Code Parser for JavaScript. +keywords: EnumCodeFormat, javascript, enum +needAutoGenerateSidebar: false +noTitleIndex: true +breadcrumbText: EnumCodeFormat +--- + +# EnumCodeFormat + +```ts +enum EnumCodeFormat{ + CF_AUTO = 0, + CF_DL_SOUTH_AFRICA = 1, + CF_DL_AAMVA = 2, + CF_AADHAAR = 6 +} +``` + diff --git a/programming/javascript/api-reference/enum/EnumErrorCode.md b/programming/javascript/api-reference/enum/EnumErrorCode.md new file mode 100644 index 0000000..a62cba8 --- /dev/null +++ b/programming/javascript/api-reference/enum/EnumErrorCode.md @@ -0,0 +1,34 @@ +--- +layout: default-layout +title: EnumErrorCode - Dynamsoft Code Parser JavaScript Enum +description: This page shows the EnumErrorCode enum of Dynamsoft Code Parser for JavaScript. +keywords: EnumErrorCode, javascript, enum +needAutoGenerateSidebar: false +noTitleIndex: true +breadcrumbText: EnumErrorCode +--- + +# EnumErrorCode + +```ts +enum EnumErrorCode{ + DCP_OK = 0, + DCP_NULL_POINTER = -10002, + DCP_LICENSE_INVALID = -10003, + DCP_LICENSE_EXPIRED = -10004, + DCP_INVALID_DATA = -90003, + DCP_INVALID_KEY = -90004, + DCP_NOT_VALID_VDS_TYPE = -90005, + DCP_VDS_CHECK_FAILED = -90006, + DCP_VDS_INVALID_CER = -90007, + DCP_VDS_INVALID_SIGNATURE = -90008, + DCP_VDS_CANNOT_OPEN_CERTIFICATE = -90009, + DCP_LICENSE_DOMAIN_NOT_MATCH = -10043, + DCP_AADHAAR_CHECK_FAILED = -90011, + DCP_NOT_SUPPORTED_YET = -10006, + DCP_NO_LICENSE = -20000, + DCP_LICENSE_SYNC_FAILED = -20003, + DCP_TRIAL_LICENSE = -20010, + DCP_FAILED_TO_REACH_DLS = -20200 +} +``` diff --git a/programming/javascript/api-reference/enum/EnumResultInfoType.md b/programming/javascript/api-reference/enum/EnumResultInfoType.md new file mode 100644 index 0000000..c3cfbc5 --- /dev/null +++ b/programming/javascript/api-reference/enum/EnumResultInfoType.md @@ -0,0 +1,22 @@ +--- +layout: default-layout +title: EnumResultInfoType - Dynamsoft Code Parser JavaScript Enum +description: This page shows the EnumResultInfoType enum of Dynamsoft Code Parser for JavaScript. +keywords: EnumResultInfoType, javascript, enum +needAutoGenerateSidebar: false +noTitleIndex: true +breadcrumbText: EnumResultInfoType +--- + +# EnumResultInfoType + +```ts +enum EnumResultInfoType{ + RIT_DRIVER_LICENSE_AAMVA = 0, + RIT_PERSONAL_ID = 1, + RIT_VDSNC = 2, + RIT_AADHAAR = 3, + RIT_DRIVER_LICENSE_SOUTH_AFRICA = 4 +} +``` + diff --git a/programming/javascript/api-reference/enum/index.md b/programming/javascript/api-reference/enum/index.md new file mode 100644 index 0000000..3427fe8 --- /dev/null +++ b/programming/javascript/api-reference/enum/index.md @@ -0,0 +1,17 @@ +--- +layout: default-layout +title: Enum Index - Dynamsoft Code Parser JavaScript API +description: This page shows the Enums of Dynamsoft Code Parser JavaScript SDK. +keywords: enums, api reference, javascript, js +needAutoGenerateSidebar: false +noTitleIndex: true +breadcrumbText: Enum Index +--- + +# Enums + +Dynamsoft Code Parser JavaScript SDK has the following enums. + +* [EnumCodeFormat](enumcodeformat.html) +* [EnumErrorCode](enumerrorcode.html) +* [EnumResultInfoType](enumresultinfotype.html) diff --git a/programming/javascript/api-reference/index.md b/programming/javascript/api-reference/index.md new file mode 100644 index 0000000..558c652 --- /dev/null +++ b/programming/javascript/api-reference/index.md @@ -0,0 +1,86 @@ +--- +layout: default-layout +title: Entry Page - Dynamsoft Code Parser JavaScript API +description: This is the main page of Dynamsoft Code Parser JavaScript SDK API Reference. +keywords: CodeParser, api reference, javascript, js +needAutoGenerateSidebar: true +needGenerateH3Content: true +noTitleIndex: true +breadcrumbText: API Reference +--- + +# JavaScript API Reference + +The Dynamsoft Code Parser JavaScript library comes with one primary class: `CodeParser`. + +## CodeParser + +A CodeParser takes code data in forms of byte array or plain string as input and returns parsed results. The following code snippet shows its basic usage: + +```js +let parser = await Dynamsoft.DCP.CodeParser.createInstance(); +parser.setCodeFormat(enumcodeformat); +let result = await parser.parseData(code); +console.log(result); +``` + +The APIs for this class include: + +### Initialize License + +| API Name | Description | +|---|---| +| [license](LicenseControl.md#license) | Initializes license of DCP. | + +### Initialize Engine + +| API Name | Description | +|---|---| +| [engineResourcePath](InitializationControl.md#engineresourcepath) | Specifies the path of WASM engine. | +| [loadWasm()](InitializationControl.md#loadwasm) | Loads and compiles the WASM. | + +### Create and Destroy + +| API Name | Description | +|---|---| +| [createInstance()](CodeParser.md#createinstance) | Creates a `CodeParser` instance. | +| [destroyContext()](CodeParser.md#destroycontext) | Destroys the `CodeParser` instance in WASM. | + +### Set Code Format + +| API Name | Description | +|---|---| +| [setCodeFormat()](CodeParser.md#setcodeformat) | Sets input code's format. | + +### Parse Code Data + +| API Name | Description | +|---|---| +| [parseData()](CodeParser.md#parsedata) | Parses code data for readable results. | + + + +## Interfaces and Enums + +In order to make the code more predictable and readable, the library defines a series of supporting interfaces and enumerations: + +### Interfaces + +* [CodeParserException](../api-reference/interface/CodeParserEception.md) +* [BasicPersonalInfo](../api-reference/interface/BasicPersonalInfo.md) +* [ParseResult](../api-reference/interface/ParseResult.md) + +### Enums + +* [EnumErrorCode](../api-reference/enum/EnumErrorCode.md) +* [EnumCodeFormat](../api-reference/enum/EnumCodeFormat.md) +* [EnumResultInfoType](../api-reference/enum/EnumResultInfoType.md) diff --git a/programming/javascript/api-reference/interface/BasicPersonalInfo.md b/programming/javascript/api-reference/interface/BasicPersonalInfo.md new file mode 100644 index 0000000..10ab0ac --- /dev/null +++ b/programming/javascript/api-reference/interface/BasicPersonalInfo.md @@ -0,0 +1,66 @@ +--- +layout: default-layout +title: BasicPersonalInfo - Dynamsoft Code Parser JavaScript Interface +description: This page shows the BasicPersonalInfo interface of Dynamsoft Code Parser for JavaScript. +keywords: BasicPersonalInfo, javascript, interface +needAutoGenerateSidebar: false +noTitleIndex: true +breadcrumbText: BasicPersonalInfo +--- + +# BasicPersonalInfo + +`interface` BasicPersonalInfo + +* idNo: *string* + +* fullName: *string* + +* firstName: *string* + +* middleName: *string* + +* lastName: *string* + +* suffix: *string* + +* givenNameAlias: *string* + +* lastNameAlias: *string* + +* suffixAlias: *string* + +* sex: *string* + +* race: *string* + +* birthPlace: *string* + +* birthYear: *number* + +* birthMonth: *number* + +* birthDay: *number* + +* addressCity: *string* + +* addressPostalCode: *string* + +* addressStreet_1: *string* + +* addressStreet_2: *string* + +* issuingCountry: *string* + +* issuedYear: *number* + +* issuedMonth: *number* + +* issuedDay: *number* + +* expirationYear: *number* + +* expirationMonth: *number* + +* expirationDay: *number* + diff --git a/programming/javascript/api-reference/interface/CodeParserException.md b/programming/javascript/api-reference/interface/CodeParserException.md new file mode 100644 index 0000000..f67655f --- /dev/null +++ b/programming/javascript/api-reference/interface/CodeParserException.md @@ -0,0 +1,19 @@ +--- +layout: default-layout +title: CodeParserException - Dynamsoft Code Parser JavaScript Interface +description: This page shows the CodeParserException interface of Dynamsoft Code Parser for JavaScript. +keywords: CodeParserException, javascript, interface +needAutoGenerateSidebar: false +noTitleIndex: true +breadcrumbText: CodeParserException +--- + +# CodeParserException + +`interface` CodeParserException + +* code: *[EnumErrorCode](../enum/EnumErrorCode.md)* + + > The error code. + + diff --git a/programming/javascript/api-reference/interface/ParseResult.md b/programming/javascript/api-reference/interface/ParseResult.md new file mode 100644 index 0000000..003539a --- /dev/null +++ b/programming/javascript/api-reference/interface/ParseResult.md @@ -0,0 +1,25 @@ +--- +layout: default-layout +title: ParseResult - Dynamsoft Code Parser JavaScript Interface +description: This page shows the ParseResult interface of Dynamsoft Code Parser for JavaScript. +keywords: ParseResult, javascript, interface +needAutoGenerateSidebar: false +noTitleIndex: true +breadcrumbText: ParseResult +--- + +# ParseResult + +`interface` ParseResult + +* resultInfoType: *number | [EnumCodeFormat](../enum/EnumCodeFormat.md)* + + > The parsed result type. + +* basicPersonalInfo: *[BasicPersonalInfo](BasicPersonalInfo.md)* + + > The common basic personal info. + +* resultInfo: *any* + + > The parsed result apart from basicPersonalInfo. diff --git a/programming/javascript/api-reference/interface/index.md b/programming/javascript/api-reference/interface/index.md new file mode 100644 index 0000000..aa63589 --- /dev/null +++ b/programming/javascript/api-reference/interface/index.md @@ -0,0 +1,17 @@ +--- +layout: default-layout +title: Interface Index - Dynamsoft Code Parser JavaScript API +description: This page shows the Interfaces of Dynamsoft Code Parser JavaScript SDK. +keywords: interfaces, api reference, javascript, js +needAutoGenerateSidebar: false +noTitleIndex: true +breadcrumbText: Interface Index +--- + +# Interfaces + +Dynamsoft Code Parser JavaScript SDK has the following interfaces. + +* [BasicPersonalInfo](basicpersonalinfo.html) +* [CodeParserException](codeparserexception.html) +* [ParseResult](parseresult.html) diff --git a/programming/javascript/index.md b/programming/javascript/index.md new file mode 100644 index 0000000..130f803 --- /dev/null +++ b/programming/javascript/index.md @@ -0,0 +1,22 @@ +--- +layout: default-layout +title: Main Page - Dynamsoft Code Parser for JavaScript +description: This is the main page of Dynamsoft Code Parser for JavaScript Language. +keywords: javascript +needAutoGenerateSidebar: true +needGenerateH3Content: true +--- + +# JavaScript Documentation + +## Getting Started + +- [User Guide](user-guide.md) + +## API Reference + +- [API Reference](api-reference/index.md) + +## Release Notes + +- [Version 1.x](release-notes/js-1.md) diff --git a/programming/javascript/release-notes/index.md b/programming/javascript/release-notes/index.md new file mode 100644 index 0000000..18e49ff --- /dev/null +++ b/programming/javascript/release-notes/index.md @@ -0,0 +1,13 @@ +--- +layout: default-layout +title: Release Notes - Dynamsoft Code Parser JavaScript SDK +description: This is the release notes page of Dynamsoft Code Parser JavaScript SDK. +keywords: release notes, javascript +needAutoGenerateSidebar: false +breadcrumbText: Release Notes +--- + +# Dynamsoft Code Parser JavaScript SDK - Release Notes + +- [1.1.0 (07/19/2022)](js-1.md/#110-07192022) +- [1.0.2 (06/08/2022)](js-1.md/#102-06082022) diff --git a/programming/javascript/release-notes/js-1.md b/programming/javascript/release-notes/js-1.md new file mode 100644 index 0000000..7fd1b84 --- /dev/null +++ b/programming/javascript/release-notes/js-1.md @@ -0,0 +1,40 @@ +--- +layout: default-layout +title: Release Notes v1.x - Dynamsoft Code Parser JavaScript SDK +description: This is the release notes page for Dynamsoft Code Parser JavaScript SDK v1.x. +keywords: release notes, javascript +needAutoGenerateSidebar: true +needGenerateH3Content: false +noTitleIndex: true +--- + +# Release Notes for JavaScript SDK - 1.x + +## 1.1.0 (07/18/2022) + +### Add + +* Add `CF_AADHAAR` to EnumCodeFormat. +* Add `RIT_AADHAAR` to EnumResultInfoType. +* Add some new enums to [EnumErrorCode](../api-reference/enum/EnumErrorCode.md). + +### Change + +* Change `CF_DL_AAMVA_ANSI` to `CF_DL_AAMVA`. +* Change `RIT_DRIVER_LICENSE_INFO` to `RIT_DRIVER_LICENSE_AAMVA` and `RIT_DRIVER_LICENSE_SOUTH_AFRICA`. +* Change `RIT_PERSONAL_ID_INFO` to `RIT_PERSONAL_ID`. +* Change `RIT_VDSNC_INFO` to `RIT_VDSNC`. + +## 1.0.2 (06/08/2022) + +### New + +* New property `license` to control license of DCP. +* New property `engineResourcePath` to specify the path of DCP WASM engine. +* New `loadWasm()` to `CodeParser` to load and compile the WASM. +* New method `createInstance()` to `CodeParser` to create a CodeParser instance. +* New method `destroyContext()` to `CodeParser` to destroy the CodeParser instance in WASM. +* New method `setCodeFormat()` to `CodeParser` to set what type of code you want to parse. +* New method `parseData()` to `CodeParser` to parse code. +* New method `setCryptoPyblicKey()` to `CodeParser` to set a public key if code parsing needs. +* New method `setCertificate()` to `CodeParser` to set a certificate if code parsing needs. diff --git a/programming/javascript/user-guide.md b/programming/javascript/user-guide.md new file mode 100644 index 0000000..3781bef --- /dev/null +++ b/programming/javascript/user-guide.md @@ -0,0 +1,227 @@ +--- +layout: default-layout +title: User Guide - Dynamsoft Code Parser for JavaScript +description: This is the user guide page of Dynamsoft Code Parser for JavaScript SDK. +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 DCP-JS SDK into your website. + +Table of Contents + +* [Hello World - Simplest Implementation](#hello-world---simplest-implementation) +* [Building your own page](#building-your-own-page) + * [Include the SDK](#include-the-sdk) + * [Configure the SDK](#configure-the-sdk) + * [Interact with the SDK](#interact-with-the-sdk) +* [API Documentation](#api-documentation) + +## Hello World - Simplest Implementation + +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 codes into readable info. + +The complete code of the "Hello World" example is shown below: + +> Since the code that needs parsing is usually hard to understand and often comes from images, we choose an online image which contains a US driver license to demonstrate how to parse the code with the help of `BarcodeReader` . Please make sure your device is connected to the Internet when opening the following example in your browser. + +```html + + + + + + + + + + +``` + +### About the code + +* `license`: This property specifies a license key. Read more on [Specify the license](#specify-the-license). + +* `createInstance()`: This method creates a CodeParser object. + +* `setCodeFormat`: This method sets the code's format before parsing. + +* `parseData`: This method parses the code. + +For the rest of the code, please read more about [DBR-JS User Guide](https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/). + +## 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: + +* yarn + + ```cmd + yarn add dynamsoft-code-parser + ``` + +* npm + + ```cmd + npm install dynamsoft-code-parser --save + ``` + +Depending on how you downloaded the SDK and where you put it, you can typically include it like this: + +```html + +``` + +or + +```html + +``` + +### 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 API `license` 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.DCP.CodeParser.license = "YOUR-LICENSE-KEY"; +``` + +#### Specify the location of the "engine" files + +This is usually only required with frameworks like Angular or React, etc. where dcp.js is 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 `engineResourcePath` : + +```javascript +//The following code uses the jsDelivr CDN, feel free to change it to your own location of these files +Dynamsoft.DCP.CodeParser.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-code-parser@1.1.0/dist/"; +``` + +### Interact with the SDK + +#### Create a `CodeParser` object + +To use the SDK, we first create a CodeParser object. + +```javascript +Dynamsoft.DCP.CodeParser.license = "YOUR-LICENSE-KEY"; +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 pParser in the following code + +```javascript +Dynamsoft.DCP.CodeParser.license = "YOUR-LICENSE-KEY"; +let pParser = null; + +function foo() { + try { + const parser = await (pParser = pParser || Dynamsoft.DCP.CodeParser.createInstance()); + } catch (ex) { + console.error(ex); + } +} +``` + +#### Set code format + +Before parsing, you need to specify the format of code to parse. See [EnumCodeFormat](https://www.dynamsoft.com/code-parser/docs/web/programming/javascript/api-reference/enum/EnumCodeFormat.html?ver=1.0.2) to check if DCP-JS covers the code format you need. + +```javascript +parser.setCodeFormat(format); //format: EnumCodeFormat +``` + +#### Parse code + +The method `parseData()` takes data in three formats: `number[]`, `Uint8Array` and `string`. If you want to parse a barcode into readable info, you should first extract the information from the barcode using DBR-JS before parsing it with DCP-JS. + +> For more information on using DBR-JS, read [DBR-JS User Guide](https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/). + +```javascript +parser.parseData(data); //data: number[] | Uint8Array | string +``` + + + +## API Documentation + +For more information about the APIs of DCP-JS, read [Dynamsoft Code Parser JavaScript Edition API Reference](https://www.dynamsoft.com/code-parser/docs/web/programming/javascript/api-reference/?ver=1.1.0). diff --git a/search.md b/search.md new file mode 100644 index 0000000..95c3fe3 --- /dev/null +++ b/search.md @@ -0,0 +1,5 @@ +--- +layout: search-page +title: Dynamsoft Code Parser SDK Documentation Search +keywords: Dynamsoft Code Parser SDK Documentation Search +--- \ No newline at end of file