@regulaforensics/vp-frontend-document-components 7.5.2001-nightly → 7.5.2003-nightly
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -1596
- package/dist/index.d.ts +1 -0
- package/dist/main.iife.js +27 -27
- package/dist/main.js +20030 -18086
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,73 +1,30 @@
|
|
|
1
|
-
# Document Reader Web Components
|
|
1
|
+
# Regula Document Reader SDK Web Components
|
|
2
2
|
|
|
3
|
-
* [
|
|
4
|
-
* [
|
|
5
|
-
* [
|
|
6
|
-
* [
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* [Service Parameters](#service-parameters)
|
|
10
|
-
* [Parameters Description](#parameters-description)
|
|
11
|
-
* [Events](#events)
|
|
12
|
-
* [Action Types](#action-types)
|
|
13
|
-
* [Action Data](#action-data)
|
|
14
|
-
* [Remote action data](#remote-action-data)
|
|
15
|
-
* [Action Statuses](#action-statuses)
|
|
16
|
-
* [Action Failure Reasons](#action-failure-reasons)
|
|
17
|
-
* [Event Generation Logic](#event-generation-logic)
|
|
18
|
-
* [Event Response](#event-response)
|
|
19
|
-
* [Settings and Attributes](#settings-and-attributes)
|
|
20
|
-
* [Backend reprocessing](#backend-reprocessing)
|
|
21
|
-
* [Delegating scan to device with better camera](#delegating-scan-to-device-with-better-camera)
|
|
22
|
-
* [Appearance Customization](#appearance-customization)
|
|
23
|
-
* [Font and Colors](#font-and-colors)
|
|
24
|
-
* [Inserting component in Flex and Grid layouts](#inserting-component-in-flex-and-grid-layouts)
|
|
25
|
-
* [Localized Messages](#localized-messages)
|
|
26
|
-
* [Document Reader Processor](#document-reader-processor)
|
|
27
|
-
* [npm Processor Integration](#npm-processor-integration)
|
|
28
|
-
* [CDN Processor Integration](#cdn-processor-integration)
|
|
29
|
-
* [Processor Methods](#processor-methods)
|
|
30
|
-
* [Processor Parameters](#processor-parameters)
|
|
31
|
-
* [Package Resources](#package-resources)
|
|
32
|
-
* [Potential Problems](#potential-problems)
|
|
33
|
-
* [Examples](#examples)
|
|
34
|
-
* [Additional Resources](#additional-resources)
|
|
35
|
-
* [FAQ](#faq)
|
|
36
|
-
* [How do I collect logs?](#how-do-i-collect-logs)
|
|
3
|
+
* [How to Install](#how-to-install)
|
|
4
|
+
* [Documentation](#documentation)
|
|
5
|
+
* [Demo Application](#demo-application)
|
|
6
|
+
* [Sample Projects](#sample-projects)
|
|
7
|
+
* [Technical Support](#technical-support)
|
|
8
|
+
* [Business Enquiries](#business-enquiries)
|
|
37
9
|
|
|
38
|
-
|
|
10
|
+
## How to Install
|
|
39
11
|
|
|
40
|
-
|
|
12
|
+
Document Reader Web Components package contains a number of predefined and configurable components, as described in the table below.
|
|
41
13
|
|
|
42
|
-
|
|
14
|
+
| Component | Description |
|
|
15
|
+
|-------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
16
|
+
| <span style="white-space: nowrap">[Smart capture](#smart-capture-component)</span> <br/>(`document-reader`) | Recommended component for most cases, as it is easy to integrate yet flexibly configurable.<br/> <ul><li>Takes photo by the device's camera **automatically**, when the document is presented in the frame in focus.</li> <li>Can take photo **manually** by using dedicated capture button.</li> <li>Provides predefined UI and behavior.</li> <li>Have wide range of configurable parameters.</li><ul> |
|
|
17
|
+
| [Snapshot](#snapshot-component) <br/> <span style="white-space: nowrap">(`camera-snapshot`)</span> | <ul><li>Can take photo **manually** by using dedicated capture button.</li><li>Provides predefined UI and behavior.</li><li>Have wide range of configurable parameters.</li></ul> |
|
|
18
|
+
| <a target="_blank" href="https://docs.regulaforensics.com/develop/doc-reader-sdk/web-components/advanced/">Advanced</a> | <ul><li>Can handle the extended range of the document recognition tasks.</li><li>Provides the most advanced configuration capabilities.</li><li>Has no predefined graphical interface, leaving UI implementation to you.</li></ul> |
|
|
43
19
|
|
|
44
|
-
|
|
45
|
-
* Process an uploaded image
|
|
46
|
-
* Crop the image by document boundaries
|
|
47
|
-
* Detect the presence of a machine-readable zone (MRZ), recognize it, and parse into text text fields
|
|
48
|
-
* Read barcodes, and parse them into text fields
|
|
20
|
+
### Before You Start
|
|
49
21
|
|
|
50
|
-
|
|
22
|
+
* Never keep the license in production environment. On production environments, the <a target="_blank" href="https://docs.regulaforensics.com/develop/doc-reader-sdk/overview/licensing/#domain-name-licensing">domain name licensing</a> must be used. Using the explicit license in the source code of your project is applicable only in development and for testing.
|
|
23
|
+
* Using HTTPS protocol is a must. Document Reader Web Components use the `getUserMedia` method to display the video stream from the camera—this feature is available only in secure contexts.
|
|
24
|
+
* The Web Components are registered on the web page itself, so make sure to import the library to your website before adding any of the components to the web page code.
|
|
25
|
+
* Only the modern browser versions are supported, see the [compatibility](#compatibility) section. Polyfills are not included in the package by default.
|
|
51
26
|
|
|
52
|
-
|
|
53
|
-
Document Reader UI Web Components with predefined view and behavior are designed for the fast integration of document recognition functionality into your project.
|
|
54
|
-
You can still customize most of the appearance and processing parameters before the launch if needed.
|
|
55
|
-
Examples of the UI Web Components are `document-reader` for documents recognition, `camera-snapshot` for capturing images from a camera or uploading from a gallery.
|
|
56
|
-
* [Processor](#document-reader-processor)
|
|
57
|
-
Document Reader Processor manages the document image recognition and other related operations, leaving implementation of UI to you.
|
|
58
|
-
|
|
59
|
-
Current document acts as a quick start guide for operating Document Reader Web Components and as a reference to their main processing parameters.
|
|
60
|
-
|
|
61
|
-
## Before You Start
|
|
62
|
-
|
|
63
|
-
Important notes:
|
|
64
|
-
|
|
65
|
-
* **Never** keep the license in **production** environment. On production environments, the <a href="https://docs.regulaforensics.com/develop/doc-reader-sdk/overview/licensing">domain name licensing</a> method must be used. Using the license in the source code of your project is applicable only in development and for testing.
|
|
66
|
-
* Document Reader Web Components and their methods strictly require the secure contexts, so using **HTTPS** protocol is a must.
|
|
67
|
-
* The considered components are registered on the **web page itself**, so make sure to import the library to your website before adding any of the components to the web page code.
|
|
68
|
-
* Only the modern browser versions are supported, see [compatibility](#compatibility). **Polyfills** are not included in the package by default.
|
|
69
|
-
|
|
70
|
-
## Compatibility
|
|
27
|
+
### Compatibility
|
|
71
28
|
|
|
72
29
|
| Devices |  |  |  |
|
|
73
30
|
|:---------------------|:-------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------:|
|
|
@@ -78,109 +35,52 @@ Important notes:
|
|
|
78
35
|
To support the older browser versions in your project, install the required polyfill packages manually.
|
|
79
36
|
Follow the link to npm package <a href="https://www.npmjs.com/package/@webcomponents/webcomponentsjs" target="_blank">@webcomponents/webcomponentsjs</a> for installation details.
|
|
80
37
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
### npm Service Integration
|
|
38
|
+
### Step 1: Install Library
|
|
84
39
|
|
|
85
|
-
|
|
40
|
+
* [npm](#npm)
|
|
41
|
+
* [CDN](#cdn)
|
|
86
42
|
|
|
87
|
-
|
|
88
|
-
npm i @regulaforensics/vp-frontend-document-components
|
|
89
|
-
```
|
|
43
|
+
#### npm
|
|
90
44
|
|
|
91
|
-
|
|
45
|
+
1\. Install the package <a href="https://www.npmjs.com/package/@regulaforensics/vp-frontend-document-components" target="_blank">vp-frontend-document-components</a>:
|
|
92
46
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
import { defineComponents, DocumentReaderService } from '@regulaforensics/vp-frontend-document-components';
|
|
96
|
-
```
|
|
97
|
-
Without module bundler:
|
|
98
|
-
```javascript
|
|
99
|
-
import { defineComponents, DocumentReaderService } from './node_modules/@regulaforensics/vp-frontend-document-components/dist/main.js';
|
|
47
|
+
```bash
|
|
48
|
+
npm i @regulaforensics/vp-frontend-document-components
|
|
100
49
|
```
|
|
101
50
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
If you need only the `camera-snapshot` component, call the `defineComponents()` method without arguments:
|
|
105
|
-
```javascript
|
|
106
|
-
defineComponents();
|
|
107
|
-
```
|
|
51
|
+
2\. Import the function `defineComponents` and the class `DocumentReaderService` into your `.js` file:
|
|
108
52
|
|
|
109
|
-
|
|
53
|
+
* With module bundler:
|
|
110
54
|
|
|
111
|
-
**1.** Add `DocumentReaderService` to the global variable `RegulaDocumentSDK` and set processing scenario:
|
|
112
55
|
```javascript
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
window.RegulaDocumentSDK.recognizerProcessParam = {
|
|
116
|
-
processParam: {
|
|
117
|
-
scenario: 'MrzAndLocate',
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
window.RegulaDocumentSDK.imageProcessParam = {
|
|
121
|
-
processParam: {
|
|
122
|
-
scenario: 'MrzAndLocate',
|
|
123
|
-
},
|
|
124
|
-
};
|
|
56
|
+
import { defineComponents, DocumentReaderService } from '@regulaforensics/vp-frontend-document-components';
|
|
125
57
|
```
|
|
126
|
-
**2.** Define the components and initialize the service:
|
|
127
58
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
```javascript
|
|
131
|
-
defineComponents().then(() => window.RegulaDocumentSDK.initialize());
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
On **test environment** (with generated Base64 license string):
|
|
59
|
+
* Without module bundler:
|
|
135
60
|
|
|
136
61
|
```javascript
|
|
137
|
-
defineComponents
|
|
62
|
+
import { defineComponents, DocumentReaderService } from './node_modules/@regulaforensics/vp-frontend-document-components/dist/main.js';
|
|
138
63
|
```
|
|
139
64
|
|
|
140
|
-
|
|
141
|
-
<a href="https://support.regulaforensics.com/hc/en-us/articles/15378060500881-How-to-convert-a-license-file-to-BASE64-" target="_blank">How to Convert a License File to BASE64</a> FAQ article.
|
|
65
|
+
#### CDN
|
|
142
66
|
|
|
143
|
-
|
|
67
|
+
Connect the script to your `.html` file. Use a CDN link in the following format: `unpkg.com/:package@:version/:file`.
|
|
144
68
|
|
|
145
69
|
For example:
|
|
146
70
|
|
|
147
|
-
`document-reader` is used for the document recognition with defined parameters:
|
|
148
|
-
```html
|
|
149
|
-
<document-reader></document-reader>
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
`camera-snapshot` is used to capture images from the device's camera and to import from the gallery:
|
|
153
|
-
```html
|
|
154
|
-
<camera-snapshot></camera-snapshot>
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### CDN Service Integration
|
|
158
|
-
|
|
159
|
-
**Step 1.** Connect the script to your `.html` file.
|
|
160
|
-
|
|
161
|
-
Use the CDN link in a format as follows: `unpkg.com/:package@:version/:file`
|
|
162
|
-
|
|
163
|
-
For example:
|
|
164
71
|
```html
|
|
165
72
|
<script src="https://unpkg.com/@regulaforensics/vp-frontend-document-components@latest/dist/main.iife.js"></script>
|
|
166
73
|
```
|
|
167
74
|
|
|
168
|
-
|
|
75
|
+
### Step 2: Add Component
|
|
169
76
|
|
|
170
|
-
|
|
77
|
+
* [Smart capture](#smart-capture-component)
|
|
78
|
+
* [Snapshot](#snapshot-component)
|
|
171
79
|
|
|
172
|
-
|
|
173
|
-
```javascript
|
|
174
|
-
defineComponents();
|
|
175
|
-
```
|
|
80
|
+
#### Smart Capture Component
|
|
176
81
|
|
|
177
|
-
|
|
82
|
+
1\. Add `DocumentReaderService` to the global variable `RegulaDocumentSDK` and set a <a target="_blank" href="https://docs.regulaforensics.com/develop/doc-reader-sdk/web-components/getting-started/scenarios/">processing scenario</a>:
|
|
178
83
|
|
|
179
|
-
**1.** Access `DocumentReaderService` and `defineComponents` via the global variable `window.Regula`:
|
|
180
|
-
```javascript
|
|
181
|
-
const { defineComponents, DocumentReaderService } = window.Regula;
|
|
182
|
-
```
|
|
183
|
-
**2.** Add `DocumentReaderService` to the global variable `RegulaDocumentSDK` and set processing scenario:
|
|
184
84
|
```javascript
|
|
185
85
|
window.RegulaDocumentSDK = new DocumentReaderService();
|
|
186
86
|
|
|
@@ -195,1495 +95,66 @@ window.RegulaDocumentSDK.imageProcessParam = {
|
|
|
195
95
|
},
|
|
196
96
|
};
|
|
197
97
|
```
|
|
198
|
-
**3.** Define the components and initialize the service.
|
|
199
|
-
|
|
200
|
-
On **production environment** (the <a href="https://docs.regulaforensics.com/develop/doc-reader-sdk/overview/licensing">domain name licensing</a> is used):
|
|
201
|
-
```javascript
|
|
202
|
-
defineComponents().then(() => window.RegulaDocumentSDK.initialize());
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
On **test environment** (with generated Base64 license string):
|
|
206
|
-
```javascript
|
|
207
|
-
defineComponents().then(() => window.RegulaDocumentSDK.initialize({ license: 'BASE64_LICENSE_KEY' }));
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
For more information about licensing, see the <a href="https://docs.regulaforensics.com/develop/doc-reader-sdk/overview/licensing/" target="_blank">Document Reader SDK Licensing</a> page and the
|
|
211
|
-
<a href="https://support.regulaforensics.com/hc/en-us/articles/15378060500881-How-to-convert-a-license-file-to-BASE64-" target="_blank">How to Convert a License File to BASE64</a> FAQ article.
|
|
212
|
-
|
|
213
|
-
### Service Parameters
|
|
214
|
-
|
|
215
|
-
After adding `DocumentReaderService` to the global variable, you can change the default document recognition and image processing settings as follows:
|
|
216
|
-
|
|
217
|
-
**Image recognition** (video capture) default settings. The functionality is available via the camera button.
|
|
218
|
-
```javascript
|
|
219
|
-
window.RegulaDocumentSDK.recognizerProcessParam = {
|
|
220
|
-
processParam: {
|
|
221
|
-
returnUncroppedImage: true,
|
|
222
|
-
multipageProcessing: false,
|
|
223
|
-
returnPackageForReprocess: false,
|
|
224
|
-
timeout: 20000,
|
|
225
|
-
resultTypeOutput: [],
|
|
226
|
-
imageQa: {
|
|
227
|
-
expectedPass: ['dpiThreshold', 'glaresCheck', 'focusCheck'],
|
|
228
|
-
dpiThreshold: 130,
|
|
229
|
-
glaresCheck: true,
|
|
230
|
-
glaresCheckParams: {
|
|
231
|
-
imgMarginPart: 0.05,
|
|
232
|
-
maxGlaringPart: 0.01,
|
|
233
|
-
},
|
|
234
|
-
},
|
|
235
|
-
},
|
|
236
|
-
};
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
**Session ID** for video processing:
|
|
240
|
-
```javascript
|
|
241
|
-
window.RegulaDocumentSDK.recognizerProcessParam = {
|
|
242
|
-
tag: 'your session id',
|
|
243
|
-
};
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
**Image processing** default settings. The functionality is available via the gallery button.
|
|
247
|
-
```javascript
|
|
248
|
-
window.RegulaDocumentSDK.imageProcessParam = {
|
|
249
|
-
processParam: {
|
|
250
|
-
returnUncroppedImage: true,
|
|
251
|
-
returnPackageForReprocess: false,
|
|
252
|
-
},
|
|
253
|
-
};
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
**Session ID** for image processing:
|
|
257
|
-
```javascript
|
|
258
|
-
window.RegulaDocumentSDK.imageProcessParam = {
|
|
259
|
-
tag: 'your session id',
|
|
260
|
-
};
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
#### Parameters Description
|
|
264
|
-
|
|
265
|
-
| Setting | Info | Data type | Default value | Values |
|
|
266
|
-
|:-------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------:|:---------------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
|
267
|
-
| **returnUncroppedImage** | When enabled, returns input images in output. | boolean | `true` | `true`, `false` |
|
|
268
|
-
| **scenario** | Recognition scenario. | string | 'MrzAndLocate' | 'MrzAndLocate', 'MrzOrLocate', 'Mrz', 'Locate' |
|
|
269
|
-
| **multipageProcessing** | Whether to enable multi-page document processing mode. | boolean | `true` | `true`, `false` |
|
|
270
|
-
| **timeout** | Recognition timeout in milliseconds. After this time process will be finished. | number | 2000 | numbers > 0 |
|
|
271
|
-
| **timeoutFromFirstDetect** | Start the countdown from the moment the document is detected. | number | 5000 | numbers > 0 |
|
|
272
|
-
| **resultTypeOutput** | Types of results to return in response. [] - all available types. | number[] | [] | `1` - DocumentImageResult, `3` - TextDataResult, `5` - DocBarCodeInfo, `6` - GraphicsResult, `8` - DocumentTypesCandidatesResult, `9` - ChosenDocumentTypeResult, `20` - AuthenticityResult, `15` - LexicalAnalysisResult, `17` - TextDataResult, `18` - TextDataResult, `19` - GraphicsResult, `30` - ImageQualityResult, `33` - StatusResult, `36` - TextResult, `37` - ImagesResult, `85` - DocumentPositionResult, `102` - TextDataResult, `103` - GraphicsResult, `50` - LicenseResult, `49` - EncryptedRCLResult |
|
|
273
|
-
| **returnPackageForReprocess** | When enabled, returns the package for reprocessing on the backend. | boolean | `false` | `true`, `false` |
|
|
274
|
-
| **imageQa** | When enabled, image quality checks status affects document optical and overall status. | | | |
|
|
275
|
-
| **expectedPass** | Activated image quality checks. | string[] | ['dpiThreshold', 'glaresCheck', 'focusCheck'] | 'dpiThreshold', 'glaresCheck', 'focusCheck' |
|
|
276
|
-
| **dpiThreshold** | This parameter sets threshold for Image QA check of the presented document physical dpi. If actual document dpi is below this threshold, check will fail. | number | 150 | numbers > 0 |
|
|
277
|
-
| **glaresCheck** | This option enables glares check while performing image quality validation. | boolean | `true` | `true`, `false` |
|
|
278
|
-
| **glaresCheckParams** | Settings for glare check. | | | |
|
|
279
|
-
| **imageOutputMaxHeight** | This parameter allows setting maximum height in pixels of output images and thus reducing image size to desired. Does not change the aspect ratio. Changes disabled if equals to 0. | number | 0 | numbers > 0 |
|
|
280
|
-
| **imageOutputMaxWidth** | This parameter allows setting maximum width in pixels of output images and thus reducing image size to desired. Does not change the aspect ratio. Changes disabled if equals to 0. | number | 0 | numbers > 0 |
|
|
281
|
-
| **dateFormat** | This option allows you to set dates format so that solution will return dates in this format. For example, if you supply 'MM/dd/yyyy', and document have printed date '09 JUL 2020' for the date os issue, you will get '07/09/2020' as a result. By default it is set to system locale default (where the service is running). | string | | 'MM/dd/yyyy' |
|
|
282
|
-
| **measureSystem** | This option allows you to set the system of measurement used for converting original values in document to output result values. Metric by default. | number | 0 | `0` - Metric, `1` - Imperial |
|
|
283
|
-
| **imageDpiOutMax** | This parameter controls maximum resolution in dpi of output images. Resolution will remain original in case 0 is supplied. By default is set to return images in response with resolution not greater than 300 dpi for all scenarios except FullAuth. In FullAuth scenario this limit is 1000 dpi by default. | number | | numbers > 0 |
|
|
284
|
-
| **alreadyCropped** | This option can be enabled if you know for sure that the image you provide contains already cropped document by its edges. This was designed to process on the server side images captured and cropped on mobile. | boolean | `false` | `true`, `false` |
|
|
285
|
-
| **customParams** | This option allows passing custom processing parameters that can be implemented in future without changing API. | Object | {} | |
|
|
286
|
-
| **fastDocDetect** (deprecated) | When enabled, shorten the list of candidates to process during document detection in a single image process mode. Reduces processing time for specific backgrounds. | boolean | `true` | `true`, `false` |
|
|
287
|
-
| **updateOCRValidityByGlare** | When enabled, fail OCR field validity, if there is a glare over the text field on the image. | boolean | `false` | `true`, `false` |
|
|
288
|
-
| **returnCroppedBarcode** | When enabled, returns cropped barcode images for unknown documents. | boolean | `false` | `true`, `false` |
|
|
289
|
-
| **respectImageQuality** | When enabled, image quality checks status affects document optical and overall status. | boolean | `false` | `true`, `false` |
|
|
290
|
-
| **forceDocFormat** | Force use of specified document format when locating and recognizing document to reduce the number of candidates. | number | | `0` - ID1 document format, `1` - ID2 document format, `2` - ID3 document format, `3` - Undefined document format, `4` - A4 document format, `5` - ID3 double document format, `10` - ID1 format document rotated 90°, `11` - ID1 format document rotated 180°, `12` - ID1 format document rotated 270°, `13` - ID2 format document rotated 90°, `14` - ID3 format document rotated 180°, `1000` - Arbitrary format, `1002` - Flexible format. Standard formats can be resized during cropping, depending on various factors: light, background... |
|
|
291
|
-
| **noGraphics** | When enabled, no graphic fields will be cropped from document image. | boolean | `false` | `true`, `false` |
|
|
292
|
-
| **documentAreaMin** | Specifies minimal area of the image that document should cover to be treated as candidate when locating. Value should be in range from 0 to 1, where 1 is when document should fully cover the image. | number | 0 | 0 - 1 |
|
|
293
|
-
| **depersonalizeLog** | When enabled, all personal data will be forcibly removed from the logs. | boolean | `false` | `true`, `false` |
|
|
294
|
-
| **multiDocOnImage** | This option allows locating and cropping multiple documents from one image if enabled. | boolean | `false` | `true`, `false` |
|
|
295
|
-
| **shiftExpiryDate** | This option allows shifting the date of expiry into the future or past for number of months specified. This is useful, for example, in some cases when document might be still valid for some period after original expiration date to prevent negative validity status for such documents. Or by shifting the date to the past will set negative validity for the documents that is about to expire in a specified number of months. | number | 0 | numbers > 0 |
|
|
296
|
-
| **minimalHolderAge** | This options allows specifying the minimal age in years of the document holder for the document to be considered valid. | number | 0 | numbers > 0 |
|
|
297
|
-
| **mrzFormatsFilter** | This option allows limiting MRZ formats to be recognized by specifying them in array. | string[] | [] | `'1x30'` - IDL, `'3x30'` - ID1, `'2x36'` - ID2, `'2x44'` - ID3, `'1x6'` - CAN, `'2x30'` - ID1 2x30 |
|
|
298
|
-
| **forceReadMrzBeforeLocate** | When enabled, make sure that in series processing MRZ is located fully inside the result document image, if present on the document. Enabling this option may add extra processing time, by disabling optimizations, but allows more stability in output image quality. | boolean | `false` | `true`, `false` |
|
|
299
|
-
| **parseBarcodes** | This option can be disabled to stop parsing after barcode is read. | boolean | `true` | `true`, `false` |
|
|
300
|
-
| **splitNames** | When enabled, the Surname and GivenNames fields will be divided into ft_First_Name, ft_Second_Name, ft_Third_Name, ft_Fourth_Name, ft_Last_Name fields. | boolean | `false` | `true`, `false` |
|
|
301
|
-
| **backendProcessing** | When enabled, it prepares the processing result to be sent to the backend for re-processing. Use ```service.finalizePackage();``` after receiving the processing results to send them to the backend. | Object | {} | { serviceURL: 'URL', httpHeaders: { key1: 'header1', key2: 'header2', ... } } |
|
|
302
|
-
| **generateNumericCodes** | This parameter is used to generate numeric representation for issuing state and nationality codes. | boolean | | `true`, `false` |
|
|
303
|
-
|
|
304
|
-
**Attention!** If the `multipage-processing` or `internal-scenario` attributes are set, the corresponding `multipageProcessing` and `scenario` parameters' values are ignored.
|
|
305
|
-
|
|
306
|
-
### Events
|
|
307
|
-
|
|
308
|
-
The main idea of a subscription to different events is to detect the specific state changes of the concrete component.
|
|
309
|
-
For the convenience, the event has the same name as the component that it belongs to.
|
|
310
|
-
|
|
311
|
-
For example, the next code snippet adds the event listeners to `document-reader` and `camera-snapshot` components:
|
|
312
|
-
|
|
313
|
-
```javascript
|
|
314
|
-
const documentReaderComponent = document.querySelector('document-reader');
|
|
315
|
-
const cameraSnapshotComponent = document.querySelector('camera-snapshot');
|
|
316
|
-
|
|
317
|
-
documentReaderComponent.addEventListener('document-reader', (event) => console.log(event.detail));
|
|
318
|
-
cameraSnapshotComponent.addEventListener('camera-snapshot', (event) => console.log(event.detail));
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
To provide the detailed information about how the event was generated and executed, the special object `event.detail` is generated.
|
|
322
|
-
See `event.detail` object structure in the following code snippet:
|
|
323
|
-
|
|
324
|
-
```javascript
|
|
325
|
-
{
|
|
326
|
-
action: 'PRESS_CAMERA_BUTTON',
|
|
327
|
-
data: null,
|
|
328
|
-
}
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
The fields of the `event.detail` object:
|
|
332
|
-
* `action` contains the type of action that generated the component's event. For more information, see all available [action types](#action-types).
|
|
333
|
-
* `data` keeps the object with status of executed action and the payload. For more information, see the [action data](#action-data) section.
|
|
334
|
-
|
|
335
|
-
#### Action Types
|
|
336
|
-
|
|
337
|
-
| Type of action | Description of the action | Components and events, where present |
|
|
338
|
-
|:------------------------------|:------------------------------------------------------------------|:------------------------------------:|
|
|
339
|
-
| `ELEMENT_VISIBLE` | Component is appended in the DOM. | `document-reader`, `camera-snapshot` |
|
|
340
|
-
| `PRESS_CAMERA_BUTTON` | The "Camera" button is pressed. | `document-reader`, `camera-snapshot` |
|
|
341
|
-
| `PRESS_FILE_BUTTON` | The "Files" button is pressed. | `document-reader`, `camera-snapshot` |
|
|
342
|
-
| `PRESS_RETRY_BUTTON` | The "Retry" button is pressed. | `document-reader`, `camera-snapshot` |
|
|
343
|
-
| `PRESS_SKIP_BUTTON` | The "Skip" button is pressed. | `document-reader` |
|
|
344
|
-
| `PRESS_CAPTURE_BUTTON` | The "Capture" button is pressed. | `document-reader`, `camera-snapshot` |
|
|
345
|
-
| `PRESS_CHANGE_CAMERA_BUTTON` | The "Change camera" button is pressed. | `document-reader`, `camera-snapshot` |
|
|
346
|
-
| `PRESS_REMOTE_DEVICE_BUTTON` | The "Mobile device" button is pressed. | `document-reader` |
|
|
347
|
-
| `PRESS_MIRRORING_BUTTON` | The "Mirroring" button is pressed. | `document-reader`, `camera-snapshot` |
|
|
348
|
-
| `NEW_PAGE_AVAILABLE` | The document contains another page. | `document-reader` |
|
|
349
|
-
| `NEW_PAGE_STARTED` | Recognition of a new page has started. | `document-reader` |
|
|
350
|
-
| `CLOSE` | The "Close" button is pressed. | `document-reader`, `camera-snapshot` |
|
|
351
|
-
| `CAMERA_PROCESS_CLOSED` | The "Close" button is pressed on the document recognition screen. | `document-reader`, `camera-snapshot` |
|
|
352
|
-
| `CAMERA_PROCESS_STARTED` | Recognition from the camera has started. | `document-reader` |
|
|
353
|
-
| `VIDEO_STARTED` | Video stream started. | `document-reader`, `camera-snapshot` |
|
|
354
|
-
| `VIDEO_STOPPED` | Video stream stopped. | `document-reader`, `camera-snapshot` |
|
|
355
|
-
| `FILE_PROCESS_STARTED` | File processing has started. | `document-reader`, `camera-snapshot` |
|
|
356
|
-
| `PROCESS_FINISHED` | The component has finished its work. | `document-reader`, `camera-snapshot` |
|
|
357
|
-
| `SERVICE_INITIALIZED` | The component has started its work. | `document-reader` |
|
|
358
|
-
| `REMOTE_TRANSACTION_UPLOADED` | Remote transaction with current tag was uploaded | `document-reader` |
|
|
359
|
-
| `REMOTE_PROCESS_FINISHED` | Remote transaction with current tag was processed | `document-reader` |
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
#### Action Data
|
|
363
|
-
|
|
364
|
-
**1.** In case of successful operation, the `event.detail.data` field is structured as follows:
|
|
365
|
-
|
|
366
|
-
```javascript
|
|
367
|
-
{
|
|
368
|
-
response: { ... },
|
|
369
|
-
status: 1
|
|
370
|
-
}
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
If video recording is enabled:
|
|
374
|
-
|
|
375
|
-
```javascript
|
|
376
|
-
{
|
|
377
|
-
response: { ... },
|
|
378
|
-
status: 1,
|
|
379
|
-
video: Blob,
|
|
380
|
-
}
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
Available fields of `event.detail.data` object:
|
|
384
|
-
* `response` contains the object with resulting payload of the event's action execution.
|
|
385
|
-
* `status` defines the status of event's action completion. For details, see [action statuses](#action-statuses).
|
|
386
|
-
* `video` video of the document scanning process (if ```videoRecord``` setting is set).
|
|
387
|
-
|
|
388
|
-
**2.** In case of event's action failure, the `event.detail.data` field is structured as follows:
|
|
389
|
-
|
|
390
|
-
```javascript
|
|
391
|
-
{
|
|
392
|
-
reason: 'CAMERA_PERMISSION_DENIED',
|
|
393
|
-
status: 0
|
|
394
|
-
}
|
|
395
|
-
```
|
|
396
|
-
|
|
397
|
-
Available fields of `event.detail.data` object:
|
|
398
|
-
* `reason` defines the reason of action's failure. For details, see [failure reasons](#action-failure-reasons).
|
|
399
|
-
* `status` defines the status of event's action completion. For details, see [action statuses](#action-statuses).
|
|
400
98
|
|
|
401
|
-
|
|
99
|
+
2\. Define the components and initialize the service:
|
|
402
100
|
|
|
403
|
-
|
|
404
|
-
|:-------|:------------|
|
|
405
|
-
| 0 | Failure |
|
|
406
|
-
| 1 | Success |
|
|
407
|
-
| 2 | Timeout |
|
|
101
|
+
* **Production** environment. <a target="_blank" href="https://docs.regulaforensics.com/develop/doc-reader-sdk/overview/licensing/#domain-name-licensing">Domain name licensing</a> is used, so don't add the license to the project source code:
|
|
408
102
|
|
|
409
|
-
#### Action Failure Reasons
|
|
410
|
-
|
|
411
|
-
| Reason | Description of the reason |
|
|
412
|
-
|:---------------------------|:-------------------------------------------------------|
|
|
413
|
-
| `WASM_ERROR` | Error in WASM |
|
|
414
|
-
| `WASM_LICENSE` | Missing or incorrect license |
|
|
415
|
-
| `FILE_SIZE` | The file size is too large |
|
|
416
|
-
| `INCORRECT_FILE` | Problems with reading the file |
|
|
417
|
-
| `INCORRECT_SCENARIO` | Scenario is not supported |
|
|
418
|
-
| `MISSING_SCENARIO` | Scenario is missing |
|
|
419
|
-
| `UNKNOWN_ERROR` | Unknown error |
|
|
420
|
-
| `NOT_SUPPORTED` | The browser is not supported |
|
|
421
|
-
| `HTTP_NOT_SUPPORTED` | The web component does not work over the http protocol |
|
|
422
|
-
| `INSECURE_PAGE_CONTEXT` | The web component does not work in insecure context |
|
|
423
|
-
| `CAMERA_UNKNOWN_ERROR` | Unknown camera error |
|
|
424
|
-
| `CAMERA_PERMISSION_DENIED` | Access to the camera is prohibited |
|
|
425
|
-
| `NO_CAMERA` | There is no camera available |
|
|
426
|
-
| `INCORRECT_CAMERA_ID` | Camera with this ID was not found |
|
|
427
|
-
| `CONNECTION_ERROR` | Connection errors |
|
|
428
|
-
| `BAD_CONFIGURATION` | Incompatible component settings are installed |
|
|
429
|
-
|
|
430
|
-
#### Remote action data
|
|
431
|
-
|
|
432
|
-
**1.** In case of remote scan scenario REMOTE_TRANSACTION_UPLOADED `event.detail` will contain the following data:
|
|
433
103
|
```javascript
|
|
434
|
-
|
|
435
|
-
action: EventActions.REMOTE_TRANSACTION_UPLOADED,
|
|
436
|
-
data: {
|
|
437
|
-
id: 1,
|
|
438
|
-
state: 1,
|
|
439
|
-
updatedAt: 'dateStr'
|
|
440
|
-
},
|
|
441
|
-
}
|
|
104
|
+
defineComponents().then(() => window.RegulaDocumentSDK.initialize());
|
|
442
105
|
```
|
|
443
|
-
Transaction id can be used to trigger reprocessing.
|
|
444
|
-
|
|
445
|
-
#### Event Generation Logic
|
|
446
|
-
|
|
447
|
-
The cases of event generation are described in the following table.
|
|
448
|
-
|
|
449
|
-
<table>
|
|
450
|
-
<thead>
|
|
451
|
-
<tr>
|
|
452
|
-
<th>Event condition </th>
|
|
453
|
-
<th>Event type</th>
|
|
454
|
-
<th>
|
|
455
106
|
|
|
456
|
-
|
|
457
|
-
</th>
|
|
458
|
-
<th>Description</th>
|
|
459
|
-
</tr>
|
|
460
|
-
</thead>
|
|
461
|
-
<tbody>
|
|
462
|
-
<tr>
|
|
463
|
-
<td>Component is mounted in the DOM.</td>
|
|
464
|
-
<td>
|
|
465
|
-
|
|
466
|
-
`document-reader`, `camera-snapshot`
|
|
467
|
-
|
|
468
|
-
</td>
|
|
469
|
-
<td>
|
|
107
|
+
* **Development** environment. Use this option only when your product is under development or testing, and you still don't expose your application to the internet, as your license needs to be added to the project source code:
|
|
470
108
|
|
|
471
109
|
```javascript
|
|
472
|
-
{
|
|
473
|
-
action: 'ELEMENT_VISIBLE',
|
|
474
|
-
data: null,
|
|
475
|
-
}
|
|
110
|
+
defineComponents().then(() => window.RegulaDocumentSDK.initialize({ license: '<BASE64_LICENSE_KEY>' }));
|
|
476
111
|
```
|
|
477
112
|
|
|
478
|
-
</
|
|
479
|
-
<td>
|
|
113
|
+
<a href="https://support.regulaforensics.com/hc/en-us/articles/15378060500881-How-to-convert-a-license-file-to-BASE64" target="_blank">How to convert a license file to the Base64 string</a>
|
|
480
114
|
|
|
481
|
-
|
|
115
|
+
!!! warning
|
|
116
|
+
Once the development is finished and your product is ready to be exposed to the internet, make sure that you have removed the license from your source code.
|
|
482
117
|
|
|
483
|
-
|
|
118
|
+
3\. Add the component tag to the `.html` file:
|
|
484
119
|
|
|
485
120
|
```html
|
|
486
|
-
<
|
|
487
|
-
<document-reader></document-reader>
|
|
488
|
-
</div>
|
|
489
|
-
```
|
|
490
|
-
|
|
491
|
-
</td>
|
|
492
|
-
</tr>
|
|
493
|
-
<tr>
|
|
494
|
-
<td>"Camera" button is pressed.</td>
|
|
495
|
-
<td>
|
|
496
|
-
|
|
497
|
-
`document-reader`, `camera-snapshot`
|
|
498
|
-
|
|
499
|
-
</td>
|
|
500
|
-
<td>
|
|
501
|
-
|
|
502
|
-
```javascript
|
|
503
|
-
{
|
|
504
|
-
action: 'PRESS_CAMERA_BUTTON',
|
|
505
|
-
data: null,
|
|
506
|
-
}
|
|
507
|
-
```
|
|
508
|
-
|
|
509
|
-
</td>
|
|
510
|
-
<td></td>
|
|
511
|
-
</tr>
|
|
512
|
-
<tr>
|
|
513
|
-
<td>"Files" button is pressed.</td>
|
|
514
|
-
<td>
|
|
515
|
-
|
|
516
|
-
`document-reader`, `camera-snapshot`
|
|
517
|
-
|
|
518
|
-
</td>
|
|
519
|
-
<td>
|
|
520
|
-
|
|
521
|
-
```javascript
|
|
522
|
-
{
|
|
523
|
-
action: 'PRESS_FILE_BUTTON',
|
|
524
|
-
data: null,
|
|
525
|
-
}
|
|
526
|
-
```
|
|
527
|
-
|
|
528
|
-
</td>
|
|
529
|
-
<td></td>
|
|
530
|
-
</tr>
|
|
531
|
-
<tr>
|
|
532
|
-
<td>"Retry" button is pressed.</td>
|
|
533
|
-
<td>
|
|
534
|
-
|
|
535
|
-
`document-reader`, `camera-snapshot`
|
|
536
|
-
|
|
537
|
-
</td>
|
|
538
|
-
<td>
|
|
539
|
-
|
|
540
|
-
```javascript
|
|
541
|
-
{
|
|
542
|
-
action: 'PRESS_RETRY_BUTTON',
|
|
543
|
-
data: null,
|
|
544
|
-
}
|
|
545
|
-
```
|
|
546
|
-
|
|
547
|
-
</td>
|
|
548
|
-
<td></td>
|
|
549
|
-
</tr>
|
|
550
|
-
<tr>
|
|
551
|
-
<td>"Skip page" button is pressed.</td>
|
|
552
|
-
<td>
|
|
553
|
-
|
|
554
|
-
`document-reader`
|
|
555
|
-
|
|
556
|
-
</td>
|
|
557
|
-
<td>
|
|
558
|
-
|
|
559
|
-
```javascript
|
|
560
|
-
{
|
|
561
|
-
action: 'PRESS_SKIP_BUTTON',
|
|
562
|
-
data: null,
|
|
563
|
-
}
|
|
564
|
-
```
|
|
565
|
-
|
|
566
|
-
</td>
|
|
567
|
-
<td>
|
|
568
|
-
|
|
569
|
-
This event available only in `document-reader`.
|
|
570
|
-
|
|
571
|
-
</td>
|
|
572
|
-
</tr>
|
|
573
|
-
<tr>
|
|
574
|
-
<td>"Capture" button is pressed.</td>
|
|
575
|
-
<td>
|
|
576
|
-
|
|
577
|
-
`document-reader`, `camera-snapshot`
|
|
578
|
-
|
|
579
|
-
</td>
|
|
580
|
-
<td>
|
|
581
|
-
|
|
582
|
-
```javascript
|
|
583
|
-
{
|
|
584
|
-
action: 'PRESS_CAPTURE_BUTTON',
|
|
585
|
-
data: null,
|
|
586
|
-
}
|
|
587
|
-
```
|
|
588
|
-
|
|
589
|
-
</td>
|
|
590
|
-
<td>
|
|
591
|
-
</td>
|
|
592
|
-
</tr>
|
|
593
|
-
<tr>
|
|
594
|
-
<td>"Change camera" button is pressed.</td>
|
|
595
|
-
<td>
|
|
596
|
-
|
|
597
|
-
`document-reader`, `camera-snapshot`
|
|
598
|
-
|
|
599
|
-
</td>
|
|
600
|
-
<td>
|
|
601
|
-
|
|
602
|
-
```javascript
|
|
603
|
-
{
|
|
604
|
-
action: 'PRESS_CHANGE_CAMERA_BUTTON',
|
|
605
|
-
data: null,
|
|
606
|
-
}
|
|
607
|
-
```
|
|
608
|
-
|
|
609
|
-
</td>
|
|
610
|
-
<td>
|
|
611
|
-
</td>
|
|
612
|
-
</tr>
|
|
613
|
-
<tr>
|
|
614
|
-
<td>"Mobile device" button is pressed.</td>
|
|
615
|
-
<td>
|
|
616
|
-
|
|
617
|
-
`document-reader`
|
|
618
|
-
|
|
619
|
-
</td>
|
|
620
|
-
<td>
|
|
621
|
-
|
|
622
|
-
```javascript
|
|
623
|
-
{
|
|
624
|
-
action: 'PRESS_REMOTE_DEVICE_BUTTON',
|
|
625
|
-
data: null,
|
|
626
|
-
}
|
|
627
|
-
```
|
|
628
|
-
|
|
629
|
-
</td>
|
|
630
|
-
<td>
|
|
631
|
-
</td>
|
|
632
|
-
</tr>
|
|
633
|
-
<tr>
|
|
634
|
-
<td>"Mirroring" button is pressed.</td>
|
|
635
|
-
<td>
|
|
636
|
-
|
|
637
|
-
`document-reader`, `camera-snapshot`
|
|
638
|
-
|
|
639
|
-
</td>
|
|
640
|
-
<td>
|
|
641
|
-
|
|
642
|
-
```javascript
|
|
643
|
-
{
|
|
644
|
-
action: 'PRESS_MIRRORING_BUTTON',
|
|
645
|
-
data: null,
|
|
646
|
-
}
|
|
647
|
-
```
|
|
648
|
-
|
|
649
|
-
</td>
|
|
650
|
-
<td>
|
|
651
|
-
</td>
|
|
652
|
-
</tr>
|
|
653
|
-
<tr>
|
|
654
|
-
<td>The document contains another page.</td>
|
|
655
|
-
<td>
|
|
656
|
-
|
|
657
|
-
`document-reader`
|
|
658
|
-
|
|
659
|
-
</td>
|
|
660
|
-
<td>
|
|
661
|
-
|
|
662
|
-
```javascript
|
|
663
|
-
{
|
|
664
|
-
action: 'NEW_PAGE_AVAILABLE',
|
|
665
|
-
data: null,
|
|
666
|
-
}
|
|
667
|
-
```
|
|
668
|
-
|
|
669
|
-
</td>
|
|
670
|
-
<td>
|
|
671
|
-
|
|
672
|
-
This event available only in `document-reader`.
|
|
673
|
-
|
|
674
|
-
</td>
|
|
675
|
-
</tr>
|
|
676
|
-
<tr>
|
|
677
|
-
<td>Recognition of a new page has started.</td>
|
|
678
|
-
<td>
|
|
679
|
-
|
|
680
|
-
`document-reader`
|
|
681
|
-
|
|
682
|
-
</td>
|
|
683
|
-
<td>
|
|
684
|
-
|
|
685
|
-
```javascript
|
|
686
|
-
{
|
|
687
|
-
action: 'NEW_PAGE_STARTED',
|
|
688
|
-
data: null,
|
|
689
|
-
}
|
|
690
|
-
```
|
|
691
|
-
|
|
692
|
-
</td>
|
|
693
|
-
<td>
|
|
694
|
-
|
|
695
|
-
This event available only in `document-reader`.
|
|
696
|
-
|
|
697
|
-
</td>
|
|
698
|
-
</tr>
|
|
699
|
-
<tr>
|
|
700
|
-
<td>"Close" button is pressed.</td>
|
|
701
|
-
<td>
|
|
702
|
-
|
|
703
|
-
`document-reader`, `camera-snapshot`
|
|
704
|
-
|
|
705
|
-
</td>
|
|
706
|
-
<td>
|
|
707
|
-
|
|
708
|
-
```javascript
|
|
709
|
-
{
|
|
710
|
-
action: 'CLOSE',
|
|
711
|
-
data: null,
|
|
712
|
-
}
|
|
713
|
-
```
|
|
714
|
-
|
|
715
|
-
</td>
|
|
716
|
-
<td></td>
|
|
717
|
-
</tr>
|
|
718
|
-
<tr>
|
|
719
|
-
<td>"Close" button is pressed on the document recognition screen.</td>
|
|
720
|
-
<td>
|
|
721
|
-
|
|
722
|
-
`document-reader`, `camera-snapshot`
|
|
723
|
-
|
|
724
|
-
</td>
|
|
725
|
-
<td>
|
|
726
|
-
|
|
727
|
-
```javascript
|
|
728
|
-
{
|
|
729
|
-
action: 'CAMERA_PROCESS_CLOSED',
|
|
730
|
-
data: null,
|
|
731
|
-
}
|
|
732
|
-
```
|
|
733
|
-
|
|
734
|
-
</td>
|
|
735
|
-
<td></td>
|
|
736
|
-
</tr>
|
|
737
|
-
<tr>
|
|
738
|
-
<td>Recognition from the camera has started.</td>
|
|
739
|
-
<td>
|
|
740
|
-
|
|
741
|
-
`document-reader`, `camera-snapshot`
|
|
742
|
-
|
|
743
|
-
</td>
|
|
744
|
-
<td>
|
|
745
|
-
|
|
746
|
-
```javascript
|
|
747
|
-
{
|
|
748
|
-
action: 'CAMERA_PROCESS_STARTED',
|
|
749
|
-
data: null,
|
|
750
|
-
}
|
|
751
|
-
```
|
|
752
|
-
|
|
753
|
-
</td>
|
|
754
|
-
<td></td>
|
|
755
|
-
</tr>
|
|
756
|
-
<tr>
|
|
757
|
-
<td>Video stream has started.</td>
|
|
758
|
-
<td>
|
|
759
|
-
|
|
760
|
-
`document-reader`, `camera-snapshot`
|
|
761
|
-
|
|
762
|
-
</td>
|
|
763
|
-
<td>
|
|
764
|
-
|
|
765
|
-
```javascript
|
|
766
|
-
{
|
|
767
|
-
action: 'VIDEO_STARTED',
|
|
768
|
-
data: null,
|
|
769
|
-
}
|
|
770
|
-
```
|
|
771
|
-
|
|
772
|
-
</td>
|
|
773
|
-
<td></td>
|
|
774
|
-
</tr>
|
|
775
|
-
<tr>
|
|
776
|
-
<td>Video stream has stopped.</td>
|
|
777
|
-
<td>
|
|
778
|
-
|
|
779
|
-
`document-reader`, `camera-snapshot`
|
|
780
|
-
|
|
781
|
-
</td>
|
|
782
|
-
<td>
|
|
783
|
-
|
|
784
|
-
```javascript
|
|
785
|
-
{
|
|
786
|
-
action: 'VIDEO_STOPPED',
|
|
787
|
-
data: null,
|
|
788
|
-
}
|
|
789
|
-
```
|
|
790
|
-
|
|
791
|
-
</td>
|
|
792
|
-
<td></td>
|
|
793
|
-
</tr>
|
|
794
|
-
<tr>
|
|
795
|
-
<td>File processing has started.</td>
|
|
796
|
-
<td>
|
|
797
|
-
|
|
798
|
-
`document-reader`, `camera-snapshot`
|
|
799
|
-
|
|
800
|
-
</td>
|
|
801
|
-
<td>
|
|
802
|
-
|
|
803
|
-
```javascript
|
|
804
|
-
{
|
|
805
|
-
action: 'FILE_PROCESS_STARTED',
|
|
806
|
-
data: null,
|
|
807
|
-
}
|
|
808
|
-
```
|
|
809
|
-
|
|
810
|
-
</td>
|
|
811
|
-
<td></td>
|
|
812
|
-
</tr>
|
|
813
|
-
<tr>
|
|
814
|
-
<td>The work of the component is completed successfully.</td>
|
|
815
|
-
<td>
|
|
816
|
-
|
|
817
|
-
`document-reader`, `camera-snapshot`
|
|
818
|
-
|
|
819
|
-
</td>
|
|
820
|
-
<td>
|
|
821
|
-
|
|
822
|
-
```javascript
|
|
823
|
-
{
|
|
824
|
-
action: 'PROCESS_FINISHED',
|
|
825
|
-
data: {
|
|
826
|
-
response: { ... },
|
|
827
|
-
status: 1
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
```
|
|
831
|
-
|
|
832
|
-
</td>
|
|
833
|
-
<td></td>
|
|
834
|
-
</tr>
|
|
835
|
-
<tr>
|
|
836
|
-
<td>The work of the component is completed by timeout.</td>
|
|
837
|
-
<td>
|
|
838
|
-
|
|
839
|
-
`document-reader`
|
|
840
|
-
|
|
841
|
-
</td>
|
|
842
|
-
<td>
|
|
843
|
-
|
|
844
|
-
```javascript
|
|
845
|
-
{
|
|
846
|
-
action: 'PROCESS_FINISHED',
|
|
847
|
-
data: {
|
|
848
|
-
response: { ... },
|
|
849
|
-
status: 2
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
```
|
|
853
|
-
|
|
854
|
-
</td>
|
|
855
|
-
<td>
|
|
856
|
-
|
|
857
|
-
This event available only in `document-reader`.
|
|
858
|
-
|
|
859
|
-
</td>
|
|
860
|
-
</tr>
|
|
861
|
-
<tr>
|
|
862
|
-
<td>The work of the component failed.</td>
|
|
863
|
-
<td>
|
|
864
|
-
|
|
865
|
-
`document-reader`, `camera-snapshot`
|
|
866
|
-
|
|
867
|
-
</td>
|
|
868
|
-
<td>
|
|
869
|
-
|
|
870
|
-
```javascript
|
|
871
|
-
{
|
|
872
|
-
action: 'PROCESS_FINISHED',
|
|
873
|
-
data: {
|
|
874
|
-
reason: 'CAMERA_PERMISSION_DENIED',
|
|
875
|
-
status: 0
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
```
|
|
879
|
-
|
|
880
|
-
</td>
|
|
881
|
-
<td></td>
|
|
882
|
-
</tr>
|
|
883
|
-
<tr>
|
|
884
|
-
<td>Component is initialized and ready to work.</td>
|
|
885
|
-
<td>
|
|
886
|
-
|
|
887
|
-
`document-reader`
|
|
888
|
-
|
|
889
|
-
</td>
|
|
890
|
-
<td>
|
|
891
|
-
|
|
892
|
-
```javascript
|
|
893
|
-
{
|
|
894
|
-
action: 'SERVICE_INITIALIZED',
|
|
895
|
-
data: null,
|
|
896
|
-
}
|
|
121
|
+
<document-reader></document-reader>
|
|
897
122
|
```
|
|
898
123
|
|
|
899
|
-
|
|
900
|
-
<td>
|
|
124
|
+
#### Snapshot Component
|
|
901
125
|
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
</td>
|
|
905
|
-
</tr>
|
|
906
|
-
<tr>
|
|
907
|
-
<td>The transaction has been successfully uploaded from the delegated device.</td>
|
|
908
|
-
<td>
|
|
909
|
-
|
|
910
|
-
`document-reader`
|
|
911
|
-
|
|
912
|
-
</td>
|
|
913
|
-
<td>
|
|
126
|
+
1\. Define the components:
|
|
914
127
|
|
|
915
128
|
```javascript
|
|
916
|
-
|
|
917
|
-
action: 'REMOTE_TRANSACTION_UPLOADED',
|
|
918
|
-
data: {
|
|
919
|
-
id: 'df4e210a-8411-411b-998e-a7c7f6b4a770',
|
|
920
|
-
state: 1,
|
|
921
|
-
updatedAt: '2024-09-19T11:05:21.473286Z'
|
|
922
|
-
},
|
|
923
|
-
}
|
|
129
|
+
defineComponents();
|
|
924
130
|
```
|
|
925
131
|
|
|
926
|
-
|
|
927
|
-
<td>
|
|
928
|
-
|
|
929
|
-
This event available only in `document-reader`.
|
|
930
|
-
|
|
931
|
-
</td>
|
|
932
|
-
</tr>
|
|
933
|
-
<tr>
|
|
934
|
-
<td>Remote processing has been completed successfully.</td>
|
|
935
|
-
<td>
|
|
936
|
-
|
|
937
|
-
`document-reader`
|
|
132
|
+
2\. Add the component tag to the `.html` file:
|
|
938
133
|
|
|
939
|
-
|
|
940
|
-
<
|
|
941
|
-
|
|
942
|
-
```javascript
|
|
943
|
-
{
|
|
944
|
-
action: 'REMOTE_PROCESS_FINISHED',
|
|
945
|
-
data: {
|
|
946
|
-
response: { ... },
|
|
947
|
-
status: 1
|
|
948
|
-
},
|
|
949
|
-
}
|
|
134
|
+
```html
|
|
135
|
+
<camera-snapshot></camera-snapshot>
|
|
950
136
|
```
|
|
951
137
|
|
|
952
|
-
|
|
953
|
-
<td>
|
|
954
|
-
|
|
955
|
-
This event available only in `document-reader`.
|
|
138
|
+
## Documentation
|
|
956
139
|
|
|
957
|
-
</
|
|
958
|
-
</tr>
|
|
959
|
-
</tbody>
|
|
960
|
-
</table>
|
|
140
|
+
<a target="_blank" href="https://docs.regulaforensics.com/develop/doc-reader-sdk/web-components/">Regula Document Reader SDK Web Components Documentation</a>
|
|
961
141
|
|
|
962
|
-
|
|
142
|
+
<a target="_blank" href="https://dev.regulaforensics.com/DocumentReaderSDK-WebComponents-Docs/">Regula Document Reader SDK Web Components API Reference</a>
|
|
963
143
|
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
```javascript
|
|
967
|
-
const component = document.querySelector('document-reader');
|
|
144
|
+
## Demo Application
|
|
968
145
|
|
|
969
|
-
|
|
970
|
-
if (event.detail.action === 'PROCESS_FINISHED' && event.detail.data.status === 1) {
|
|
971
|
-
const response = event.detail.data.response;
|
|
972
|
-
console.log(response);
|
|
973
|
-
}
|
|
974
|
-
}
|
|
146
|
+
<a target="_blank" href="https://api.regulaforensics.com/?utm_source=npm">Demo Application</a>
|
|
975
147
|
|
|
976
|
-
|
|
977
|
-
```
|
|
148
|
+
## Sample Projects
|
|
978
149
|
|
|
979
|
-
|
|
150
|
+
There are several project examples that demonstrate the integration way of Regula Document Reader SDK Web Components, visit <a target="_blank" href="https://github.com/regulaforensics/document-web-components-samples">our repository on GitHub</a>.
|
|
980
151
|
|
|
981
|
-
|
|
982
|
-
window.RegulaDocumentSDK.recognizeListener = (response) => console.log(response);
|
|
983
|
-
```
|
|
152
|
+
Visit the <a target="_blank" href="https://storybook-document.regulaforensics.com/">Storybook</a> website to see the live demo.
|
|
984
153
|
|
|
985
|
-
|
|
154
|
+
## Technical Support
|
|
986
155
|
|
|
987
|
-
|
|
988
|
-
See the description and examples below.
|
|
156
|
+
To submit a request to the Support Team, visit <a target="_blank" href="https://support.regulaforensics.com/hc/en-us/requests/new?utm_source=npm">Regula Help Center</a>.
|
|
989
157
|
|
|
990
|
-
|
|
991
|
-
```javascript
|
|
992
|
-
const element = document.createElement('document-reader');
|
|
158
|
+
## Business Enquiries
|
|
993
159
|
|
|
994
|
-
|
|
995
|
-
startScreen: true,
|
|
996
|
-
internalScenario: 'Locate',
|
|
997
|
-
multipageProcessing: true,
|
|
998
|
-
};
|
|
999
|
-
```
|
|
1000
|
-
|
|
1001
|
-
* Using attributes to configure element:
|
|
1002
|
-
```javascript
|
|
1003
|
-
<document-reader start-screen internal-scenario="Locate"></document-reader>
|
|
1004
|
-
```
|
|
1005
|
-
|
|
1006
|
-
We **recommend** using the `settings` property of the element to configure its parameters.
|
|
1007
|
-
This method gives more flexibility in setup, in addition, all new parameters in the future will be available **only** as the settings of the object (not as HTML attributes).
|
|
1008
|
-
|
|
1009
|
-
See all component's settings and attributes in the following table.
|
|
1010
|
-
|
|
1011
|
-
| Setting name | Attribute name | Description | Data type | Default value | Values | Available in |
|
|
1012
|
-
|:--------------------------------------------|:-------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------:|:----------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------:|
|
|
1013
|
-
| **locale** | **locale** | The language of the component interface. If empty, the language is selected from the browser settings, if it is not found, the system language is taken. | string | `en` | `ru`, `en`, `de`, `pl`, `it`, `hu`, `zh`, `sk`, `uk`, `fr`, `es`, `pt`, `ar`, `nl`, `id`, `vi`, `ko`, `ms`, `ro`, `el`, `tr`, `ja`, `cs`, `th`, `hi`, `bn`, `he`, `fi`, `sv`, `da`, `hr`, `no` | `document-reader`, `camera-snapshot` |
|
|
1014
|
-
| **internalScenario** | **internal-scenario** | The component document verification scenario. | string | `MrzAndLocate` | `MrzAndLocate`, `MrzOrLocate`, `Mrz`, `Locate`, `Barcode`, `MrzOrBarcode`, `BarcodeAndLocate` | `document-reader` |
|
|
1015
|
-
| **multipageProcessing** | **multipage-processing** | Whether to allow processing of two pages in cases when the component detects an ID1-sized document. Multipage processing is not triggered for documents of other formats. If `true`, the component asks for the second page and processes it. If `false`, only one page/side of the document is processed regardless the document format. | boolean | `false` | `true`, `false` | `document-reader` |
|
|
1016
|
-
| **startScreen** | **start-screen** | Whether to show the start screen with two options for the document image uploading: From camera and From gallery. If `true`, the start screen is shown. If `false`, no start screen is shown and instead the camera of the device is turned on automatically to capture the image of the document. | boolean | `false` | `true`, `false` | `document-reader`, `camera-snapshot` |
|
|
1017
|
-
| **multipleFileInput** | **multiple** | Whether to allow uploading more than one file via the file system. Can be set to `true` only if `startScreen` is `true`. | boolean | `true` | `true`, `false` | `document-reader`, `camera-snapshot` |
|
|
1018
|
-
| **cameraId** | **camera-id** | Ability to select a camera. You can get the device ID using [navigator.mediaDevices.enumerateDevices()](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/enumerateDevices). | string | `undefined` | `camera id string value` | `document-reader`, `camera-snapshot` |
|
|
1019
|
-
| **devLicense** | **license** | To use the component on test environments, set the base64 license value to the `license` attribute. | string | `undefined` | `base64 license value` | `document-reader` |
|
|
1020
|
-
| **regulaLogo** | **copyright** | Show Regula copyright footer. (deprecated, use copyright instead) | boolean | `true` | `true`, `false` | `document-reader`, `camera-snapshot` |
|
|
1021
|
-
| **changeCameraButton** | **change-camera** | Show the camera switch button. | boolean | `false` | `true`, `false` | `document-reader`, `camera-snapshot` |
|
|
1022
|
-
| **closeButton** | **close-button** | Show the close button. | boolean | `true` | `true`, `false` | `document-reader`, `camera-snapshot` |
|
|
1023
|
-
| **captureButton** | **capture-button** | Show the capture button. | boolean | `true` | `true`, `false` | `document-reader` |
|
|
1024
|
-
| **copyright** | | Show Regula copyright footer. | boolean | `true` | `true`, `false` | `document-reader`, `camera-snapshot` |
|
|
1025
|
-
| **skipButton** | | Show the skip button for the second page. | boolean | `true` | `true`, `false` | `document-reader` |
|
|
1026
|
-
| **captureMode** | | Sets the capture mode. Mode `auto` - recognition starts immediately after the camera starts working. Mode `captureFrame` - recognition of the frame received after pressing the capture button. Mode `captureVideo` - recognition begins after pressing the button, pressing the button again will send the received frame for processing. | string | `auto` | `auto`, `captureVideo`, `captureFrame` | `document-reader` |
|
|
1027
|
-
| **resolution** | | Sets the resolution of the video stream from the camera. | object | `{ width: 1920, height: 1080 }` | `{ width: number, height: number }` | `document-reader`, `camera-snapshot` |
|
|
1028
|
-
| **cameraMode** | | Selects the front or rear camera of the device. | object | `environment` | `environment`, `user` | `document-reader`, `camera-snapshot` |
|
|
1029
|
-
| **flipFrontIcon** | | Sets the front side of the document flip icon. You can set link (`https://example.link.com/icon.png`), image in base64 string (`data:image/svg+xml;base64,PHN2ZyBjbGF...`) or imported image if you use module bundler. | string | `undefined` | `link to image`, `base64 string`, `imported image` | `document-reader` |
|
|
1030
|
-
| **flipBackIcon** | | Sets the back side of the document flip icon. You can set link (`https://example.link.com/icon.png`), image in base64 string (`data:image/svg+xml;base64,PHN2ZyBjbGF...`) or imported image if you use module bundler. | string | `undefined` | `link to image`, `base64 string`, `imported image` | `document-reader` |
|
|
1031
|
-
| **cameraFrameBorderWidth** | | Sets the thickness of the document capture frame. | number | 5 | `any number` | `document-reader` |
|
|
1032
|
-
| **backgroundMaskAlpha** | | Sets the transparency of the background outside the frame. | number | 0.5 | `from 0 to 1` | `document-reader` |
|
|
1033
|
-
| **cameraFrameLandscapeAspectRatio** | | Sets the aspect ratio of the capture frame for landscape mode. | number | depends on the scenario | `any number` | `document-reader` |
|
|
1034
|
-
| **cameraFramePortraitAspectRatio** | | Sets the aspect ratio of the capture frame for portrait mode. | number | depends on the scenario | `any number` | `document-reader` |
|
|
1035
|
-
| **statusIcon** | | Show status icon. | boolean | `true` | `true`, `false` | `document-reader` |
|
|
1036
|
-
| **statusPositionMultiplier** | | Sets the vertical position of the status message. | number | `undefined` | `from 0 to 2` | `document-reader` |
|
|
1037
|
-
| **cameraFrameOffsetWidth** | | Sets the offset of the capture frame. | number | `undefined` | `any number` | `document-reader` |
|
|
1038
|
-
| **cameraFrameVerticalPositionMultiplier** | | Sets the offset of the capture frame from the top edge. | number | `undefined` | `from 0 to 2` | `document-reader` |
|
|
1039
|
-
| **cameraFrameHorizontalPositionMultiplier** | | Sets the offset of the capture frame from the right edge. | number | `undefined` | `from 0 to 2` | `document-reader` |
|
|
1040
|
-
| **cameraFrameShapeType** | | Sets the capture frame shape type. | string | `line` | `line`, `corners` | `document-reader` |
|
|
1041
|
-
| **cameraFrameLineCap** | | Sets the style of the end of the capture frame line when `cameraFrameShapeType='corners'` | string | `butt` | `butt`, `round`, `square` | `document-reader` |
|
|
1042
|
-
| **cameraFrameLineLength** | | Sets the length of the capture frame line when `cameraFrameShapeType='corners'` | number | 5 | `any number` | `document-reader` |
|
|
1043
|
-
| **cameraFrameCornerRadius** | | Sets the radius of rounding of the capture frame. | number | 15 | `any number` | `document-reader` |
|
|
1044
|
-
| **cameraFrameDefaultColor** | | Sets the color of the capture frame. | string | `rgba(255, 255, 255, 0.9)` | `any color string` | `document-reader` |
|
|
1045
|
-
| **cameraFrameActiveColor** | | Sets the capture frame color when a document is detected. | string | `rgba(30, 130, 76, 0.9)` | `any color string` | `document-reader` |
|
|
1046
|
-
| **statusTextColor** | | Sets the color of the text message status. | string | `white` | `any color string` | `document-reader`, `camera-snapshot` |
|
|
1047
|
-
| **statusBackgroundColor** | | Sets the background color of the message status. | string | `rgba(27, 16, 31, 0.5)` | `any color string` | `document-reader`, `camera-snapshot` |
|
|
1048
|
-
| **cameraFrame** | | Show the capture frame. | boolean | `true` | `true`, `false` | `document-reader` |
|
|
1049
|
-
| **captureButtonDelay** | | Show the capture button after delay. | number | `undefined` | `any number` | `document-reader` |
|
|
1050
|
-
| **nonce** | | Sets the unique nonce value to maintain the CSP policy. | string | `undefined` | `unique nonce value` | `document-reader`, `camera-snapshot` |
|
|
1051
|
-
| **videoRecord** | | Sets the ability to record a video of the document scanning process. If set to true it records the entire process. You can also set the recording delay and recording duration. The video will be available in the component response. | boolean or object | `undefined` | `true`, `false`, `{ delay: number, duration: number, bitrate: number }` | `document-reader` |
|
|
1052
|
-
| **videoCaptureMotionControl** | | Enables device shaking control. | boolean | `false` | `true`, `false` | `document-reader` |
|
|
1053
|
-
| **fromCameraButton** | | Show the camera button. | boolean | `true` | `true`, `false` | `document-reader`, `camera-snapshot` |
|
|
1054
|
-
| **uploadFileButton** | | Show the files button. | boolean | `true` | `true`, `false` | `document-reader`, `camera-snapshot` |
|
|
1055
|
-
| **mirrorButton** | | Show the mirroring button. | boolean | `false` | `true`, `false` | `document-reader`, `camera-snapshot` |
|
|
1056
|
-
| **mirrorType** | | Sets the initial value of video mirroring. | string | `mirror` - for front camera, `noMirror` - for back camera, | `mirror`, `noMirror` | `document-reader`, `camera-snapshot` |
|
|
1057
|
-
| **mobileDelegate** | | Changes the success screen in case of delegating scanning via a mobile device. | boolean | `false` | `true`, `false` | `document-reader` |
|
|
1058
|
-
|
|
1059
|
-
### Backend reprocessing
|
|
1060
|
-
|
|
1061
|
-
You can send the results to the backend for further processing:
|
|
1062
|
-
|
|
1063
|
-
**1.** Set `backendProcessing`, `serviceURL` and `httpHeaders` (optional) in processParam:
|
|
1064
|
-
```javascript
|
|
1065
|
-
window.RegulaDocumentSDK.recognizerProcessParam = {
|
|
1066
|
-
processParam: {
|
|
1067
|
-
scenario: InternalScenarios.MrzAndLocate,
|
|
1068
|
-
backendProcessing: {
|
|
1069
|
-
serviceURL: 'YOUR_SERVICE_URL',
|
|
1070
|
-
httpHeaders: { // you can set http headers if necessary
|
|
1071
|
-
key1: 'header1',
|
|
1072
|
-
key2: 'header2',
|
|
1073
|
-
key3: 'header3'
|
|
1074
|
-
}
|
|
1075
|
-
}
|
|
1076
|
-
},
|
|
1077
|
-
};
|
|
1078
|
-
```
|
|
1079
|
-
**2.** Send the data to the backend after receiving the processing results:
|
|
1080
|
-
```javascript
|
|
1081
|
-
const component = document.querySelector('document-reader');
|
|
1082
|
-
|
|
1083
|
-
function listener(event) {
|
|
1084
|
-
if (event.detail.action === 'PROCESS_FINISHED' && event.detail.data.status === 1) {
|
|
1085
|
-
window.RegulaDocumentSDK.finalizePackage();
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
|
-
component.addEventListener('document-reader', listener);
|
|
1090
|
-
```
|
|
1091
|
-
### Delegating scan to device with better camera
|
|
1092
|
-
|
|
1093
|
-
For cases when user's main device lacks camera or does not succeed to scan with given camera quality,
|
|
1094
|
-
you have an option to delegate scanning to another available device (i.e. phone).
|
|
1095
|
-
|
|
1096
|
-
#### 1. "From other phone" action may be configured on the start screen:
|
|
1097
|
-
- add 'delegateProcessing' and 'tag':
|
|
1098
|
-
```javascript
|
|
1099
|
-
processor.recognizerProcessParam = {
|
|
1100
|
-
processParam: {
|
|
1101
|
-
scenario: InternalScenarios.MrzAndLocate,
|
|
1102
|
-
},
|
|
1103
|
-
delegateProcessing: {
|
|
1104
|
-
delegateURL: 'https://your-page.com?tag={tag}', // the page which will be used by other device
|
|
1105
|
-
serviceURL: 'https://my-service.com', // your backend service
|
|
1106
|
-
httpHeaders: { // http headers if needed
|
|
1107
|
-
header: 'value'
|
|
1108
|
-
}
|
|
1109
|
-
},
|
|
1110
|
-
tag: 123 // your session id, will be added to delegateURL in place of {tag} substring
|
|
1111
|
-
}
|
|
1112
|
-
```
|
|
1113
|
-
- these settings will unlock "From other phone" option
|
|
1114
|
-
that shows the user QR Code with url (i.e. `https://your-page.com?tag=123`)
|
|
1115
|
-
- the component will emit **REMOTE_TRANSACTION_UPLOADED** event with the most recent transaction uploaded with your session tag.
|
|
1116
|
-
Transaction id may be used to trigger full process backend reprocessing (i.e use [Document Reader Webclient](https://www.npmjs.com/package/@regulaforensics/document-reader-webclient))
|
|
1117
|
-
- the component will emit **REMOTE_PROCESS_FINISHED** event with a result of the most recent processed transaction.
|
|
1118
|
-
It is similar to **PROCESS_FINISHED** event but may contain more data due to backend reprocessing
|
|
1119
|
-
|
|
1120
|
-
#### 2. Configure Delegate page component on delegateURL:
|
|
1121
|
-
- configure [backend reprocessing](#backend-reprocessing)
|
|
1122
|
-
- backendProcessing setting for the device and delegateProcessing setting for the main page must match
|
|
1123
|
-
- set transaction tag
|
|
1124
|
-
```javascript
|
|
1125
|
-
processor.recognizerProcessParam = {
|
|
1126
|
-
tag: new URL(window.location.href).searchParams.get('tag') // assume session Id tag was added to URL params
|
|
1127
|
-
}
|
|
1128
|
-
```
|
|
1129
|
-
- use the same tag as on the main page
|
|
1130
|
-
```javascript
|
|
1131
|
-
element.settings = {
|
|
1132
|
-
startScreen: false, // From camera recognition is expected
|
|
1133
|
-
mobileDelegate: true
|
|
1134
|
-
}
|
|
1135
|
-
```
|
|
1136
|
-
- use finalizePackage() to send the data for further reprocessing
|
|
1137
|
-
|
|
1138
|
-
### Appearance Customization
|
|
1139
|
-
|
|
1140
|
-
#### CSS part
|
|
1141
|
-
|
|
1142
|
-
Using ::part CSS pseudo-elements, you can set your own styles for component elements. Select the element you need in the developer console and use its part name to customize it.
|
|
1143
|
-
|
|
1144
|
-
```css
|
|
1145
|
-
document-reader::part(container) {
|
|
1146
|
-
background: red;
|
|
1147
|
-
}
|
|
1148
|
-
```
|
|
1149
|
-
|
|
1150
|
-
#### CSS variables
|
|
1151
|
-
|
|
1152
|
-
Using CSS variables, you can change the font and font size. See the table for the details.
|
|
1153
|
-
|
|
1154
|
-
| Variable | Info | Default value |
|
|
1155
|
-
|:-------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------------:|
|
|
1156
|
-
| **--font-family** | The font family of all text elements. If you change the font family, make sure to adjust the font size so the message on the start screen would fit the frame. | `Noto Sans, sans-serif` |
|
|
1157
|
-
| **--font-size** | The font size for the text elements. | `16px` |
|
|
1158
|
-
|
|
1159
|
-
The following example demonstrates the `document-reader` HTML element font customization via the custom CSS class:
|
|
1160
|
-
|
|
1161
|
-
CSS:
|
|
1162
|
-
|
|
1163
|
-
```css
|
|
1164
|
-
.my-custom-style {
|
|
1165
|
-
--font-family: Arial, sans-serif;
|
|
1166
|
-
}
|
|
1167
|
-
```
|
|
1168
|
-
|
|
1169
|
-
HTML:
|
|
1170
|
-
|
|
1171
|
-
```html
|
|
1172
|
-
<document-reader class="my-custom-style"></document-reader>
|
|
1173
|
-
```
|
|
1174
|
-
#### Inserting component in Flex and Grid layouts
|
|
1175
|
-
|
|
1176
|
-
document-reader and camera-snapshot components have **width** and **height** set to **100%** by default and therefore try to fit their container element.
|
|
1177
|
-
This should not affect correct CSS Grid positioning, but for Flexbox make sure to style document-reader dimensions and set **flex-basis**, i.e.:
|
|
1178
|
-
|
|
1179
|
-
```css
|
|
1180
|
-
document-reader.flex-item {
|
|
1181
|
-
width: auto;
|
|
1182
|
-
height: auto;
|
|
1183
|
-
flex-basis: 500px; // distinct width of your choice
|
|
1184
|
-
}
|
|
1185
|
-
```
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
#### Localized Messages
|
|
1189
|
-
|
|
1190
|
-
To change the standard component messages or any text, specify the language attribute (see `locale` in [settings and attributes](#settings-and-attributes)) to be used.
|
|
1191
|
-
You can select one from existing locales or add your custom one. See the following example:
|
|
1192
|
-
|
|
1193
|
-
```javascript
|
|
1194
|
-
const element = document.createElement('document-reader');
|
|
1195
|
-
|
|
1196
|
-
element.translations = {
|
|
1197
|
-
en: {
|
|
1198
|
-
fromCamera: 'Use your camera',
|
|
1199
|
-
},
|
|
1200
|
-
};
|
|
1201
|
-
|
|
1202
|
-
body.append(element);
|
|
1203
|
-
```
|
|
1204
|
-
|
|
1205
|
-
**Note**: To see the changes applied, don't forget to set the desired language to the `locale` attribute.
|
|
1206
|
-
|
|
1207
|
-
```html
|
|
1208
|
-
<document-reader locale="en"></document-reader>
|
|
1209
|
-
```
|
|
1210
|
-
|
|
1211
|
-
See the following table with localized labels, used in the components.
|
|
1212
|
-
|
|
1213
|
-
| Label | Default message in `en` locale | Used in |
|
|
1214
|
-
|:---------------------------------|:-------------------------------------------------------------------------------------------------------|:------------------------------------:|
|
|
1215
|
-
| **done** | Done! | `document-reader`, `camera-snapshot` |
|
|
1216
|
-
| **fileCorrupt** | This file is corrupt or not supported | `document-reader`, `camera-snapshot` |
|
|
1217
|
-
| **somethingWentWrong** | Something went wrong | `document-reader`, `camera-snapshot` |
|
|
1218
|
-
| **tryAgain** | Try again | `document-reader`, `camera-snapshot` |
|
|
1219
|
-
| **cameraUnavailable** | Camera unavailable! | `document-reader`, `camera-snapshot` |
|
|
1220
|
-
| **preparingCamera** | Preparing the camera... | `document-reader`, `camera-snapshot` |
|
|
1221
|
-
| **noCameraAvailable** | No camera available | `document-reader`, `camera-snapshot` |
|
|
1222
|
-
| **incorrectCameraId** | No camera with the specified ID found. | `document-reader`, `camera-snapshot` |
|
|
1223
|
-
| **gallery** | Gallery | `document-reader`, `camera-snapshot` |
|
|
1224
|
-
| **files** | Files | `document-reader`, `camera-snapshot` |
|
|
1225
|
-
| **camera** | Camera | `document-reader`, `camera-snapshot` |
|
|
1226
|
-
| **largeFile** | This file is too large to be uploaded | `document-reader` |
|
|
1227
|
-
| **versionNotSupported** | Your browser version is not supported | `document-reader` |
|
|
1228
|
-
| **httpNotSupported** | HTTPS is not used | `document-reader` |
|
|
1229
|
-
| **insecurePageContext** | Insecure page context | `document-reader` |
|
|
1230
|
-
| **timeout** | Timeout | `document-reader` |
|
|
1231
|
-
| **preparingService** | Preparing the service... | `document-reader` |
|
|
1232
|
-
| **placeDocumentIntoFrame** | Fit the document into the frame | `document-reader` |
|
|
1233
|
-
| **noFocus** | No camera focus | `document-reader` |
|
|
1234
|
-
| **moveCloser** | Move closer | `document-reader` |
|
|
1235
|
-
| **glaresOnDocument** | Avoid glare on the document | `document-reader` |
|
|
1236
|
-
| **holdDocumentStraight** | Hold the document straight | `document-reader` |
|
|
1237
|
-
| **documentProcessing** | Document processing... | `document-reader` |
|
|
1238
|
-
| **flipDocument** | Flip the document | `document-reader` |
|
|
1239
|
-
| **keepDeviceStill** | Hold the device still | `document-reader` |
|
|
1240
|
-
| **positionDocumentCenter** | Position the document in the center | `camera-snapshot` |
|
|
1241
|
-
| **uploadPhoto** | Upload a photo | `camera-snapshot` |
|
|
1242
|
-
| **switchToMobile** | Switch to mobile | `document-reader` |
|
|
1243
|
-
| **openPhoneCamera** | Open the camera on your mobile device, scan the QR code, and follow the link | `document-reader` |
|
|
1244
|
-
| **pleaseWait** | Please wait... | `document-reader` |
|
|
1245
|
-
| **mobileDevice** | Mobile device | `document-reader` |
|
|
1246
|
-
| **verifyYourIdentity** | Verify your identity document | `document-reader` |
|
|
1247
|
-
| **fromCameraFilesMobileDesktop** | Capture a document using the computer’s camera, or upload it from files, or scan it on a mobile device | `document-reader` |
|
|
1248
|
-
| **fromCameraGalleryMobile** | Capture a document using the computer’s camera, or upload it from gallery | `document-reader` |
|
|
1249
|
-
| **badLicense** | The license cannot be found or has expired | `document-reader` |
|
|
1250
|
-
| **fromCameraFilesDesktop** | Capture a document using the computer’s camera, or upload it from files | `document-reader` |
|
|
1251
|
-
| **fromCameraMobileDesktop** | Capture a document using the computer’s camera, or scan it on a mobile device | `document-reader` |
|
|
1252
|
-
| **fromFilesMobileDesktop** | Upload a document from files, or scan it on a mobile device | `document-reader` |
|
|
1253
|
-
| **fromCameraDesktop** | Use the computer's camera to capture a document | `document-reader` |
|
|
1254
|
-
| **fromFilesDesktop** | Pick a document from the files and upload it | `document-reader` |
|
|
1255
|
-
| **fromMobileDesktop** | Use your mobile camera to capture a document | `document-reader` |
|
|
1256
|
-
| **fromGalleryMobile** | Pick a document from the gallery and upload it | `document-reader` |
|
|
1257
|
-
| **returnToComputer** | Return to the computer | `document-reader` |
|
|
1258
|
-
| **documentCaptured** | Your document has been captured | `document-reader` |
|
|
1259
|
-
|
|
1260
|
-
## Document Reader Processor
|
|
1261
|
-
|
|
1262
|
-
DocumentReaderProcessor manages the document image recognition and other related operations, leaving implementation of UI to you.
|
|
1263
|
-
|
|
1264
|
-
### npm Processor Integration
|
|
1265
|
-
|
|
1266
|
-
**Step 1.** Install the package `@regulaforensics/vp-frontend-document-components`:
|
|
1267
|
-
```console
|
|
1268
|
-
npm i @regulaforensics/vp-frontend-document-components
|
|
1269
|
-
```
|
|
1270
|
-
|
|
1271
|
-
**Step 2.** Import the class `DocumentReaderProcessor` into your `.js` file.
|
|
1272
|
-
|
|
1273
|
-
Using module bundler:
|
|
1274
|
-
```javascript
|
|
1275
|
-
import { DocumentReaderProcessor } from '@regulaforensics/vp-frontend-document-components';
|
|
1276
|
-
```
|
|
1277
|
-
|
|
1278
|
-
Without module bundler:
|
|
1279
|
-
```javascript
|
|
1280
|
-
import { DocumentReaderProcessor } from '/node_modules/@regulaforensics/vp-frontend-document-components/dist/main.js';
|
|
1281
|
-
```
|
|
1282
|
-
|
|
1283
|
-
**Step 3.** Add a video tag to the `.html` file, then prepare and initialize `DocumentReaderProcessor`.
|
|
1284
|
-
|
|
1285
|
-
```javascript
|
|
1286
|
-
const videoElement = document.getElementById('yourVideoElement');
|
|
1287
|
-
const processor = new DocumentReaderProcessor(videoElement);
|
|
1288
|
-
|
|
1289
|
-
processor.recognizerProcessParam = {
|
|
1290
|
-
processParam: {
|
|
1291
|
-
scenario: 'MrzAndLocate',
|
|
1292
|
-
},
|
|
1293
|
-
};
|
|
1294
|
-
processor.imageProcessParam = {
|
|
1295
|
-
processParam: {
|
|
1296
|
-
scenario: 'MrzAndLocate',
|
|
1297
|
-
},
|
|
1298
|
-
};
|
|
1299
|
-
|
|
1300
|
-
try {
|
|
1301
|
-
// Variant 1 - for production environment
|
|
1302
|
-
await processor.initialize();
|
|
1303
|
-
|
|
1304
|
-
// Variant 2 - for test-only environment
|
|
1305
|
-
// await processor.initialize({ license: 'BASE64_LICENSE_KEY' });
|
|
1306
|
-
|
|
1307
|
-
const result = await processor.startRecognition();
|
|
1308
|
-
|
|
1309
|
-
processor.stopRecognition();
|
|
1310
|
-
|
|
1311
|
-
console.log(result);
|
|
1312
|
-
} catch (e) {
|
|
1313
|
-
console.log(e);
|
|
1314
|
-
}
|
|
1315
|
-
```
|
|
1316
|
-
|
|
1317
|
-
In the preceding example, the `DocumentReaderProcessor` object is created using the HTML element with the ID `yourVideoElement`.
|
|
1318
|
-
After that, `processor` needs to be initialized. There are two licensing variants:
|
|
1319
|
-
|
|
1320
|
-
**1.** <a href="https://docs.regulaforensics.com/develop/doc-reader-sdk/overview/licensing">Domain name licensing</a> (for **production** environment).
|
|
1321
|
-
|
|
1322
|
-
To get your website domain licensed, <a href="https://explore.regula.app/docs-support-request" target="_blank">contact our sales team</a>.
|
|
1323
|
-
|
|
1324
|
-
Then asynchronously call the `initialize` method without parameters:
|
|
1325
|
-
```javascript
|
|
1326
|
-
await processor.initialize();
|
|
1327
|
-
```
|
|
1328
|
-
|
|
1329
|
-
**2.** Base64 license string (for **test-only** environment).
|
|
1330
|
-
|
|
1331
|
-
Convert Regula license file to the Base64 string and then asynchronously call `initialize` method, replacing `BASE64_LICENSE_KEY` with your encoded string:
|
|
1332
|
-
```javascript
|
|
1333
|
-
await processor.initialize({ license: 'BASE64_LICENSE_KEY' });
|
|
1334
|
-
```
|
|
1335
|
-
|
|
1336
|
-
For more information about licensing, see the <a href="https://docs.regulaforensics.com/develop/doc-reader-sdk/overview/licensing/" target="_blank">Document Reader SDK Licensing</a> page and the
|
|
1337
|
-
<a href="https://support.regulaforensics.com/hc/en-us/articles/15378060500881-How-to-convert-a-license-file-to-BASE64-" target="_blank">How to Convert a License File to BASE64</a> FAQ article.
|
|
1338
|
-
|
|
1339
|
-
### CDN Processor Integration
|
|
1340
|
-
|
|
1341
|
-
**Step 1.** Connect the script to your `.html` file.
|
|
1342
|
-
|
|
1343
|
-
Use the CDN link in a format as follows: `unpkg.com/:package@:version/:file`
|
|
1344
|
-
|
|
1345
|
-
For example:
|
|
1346
|
-
```html
|
|
1347
|
-
<script src="https://unpkg.com/@regulaforensics/vp-frontend-document-components@latest/dist/main.iife.js"></script>
|
|
1348
|
-
```
|
|
1349
|
-
|
|
1350
|
-
**Note:** You can find all available script versions in the corresponding section of npm, using the same link from the previous example.
|
|
1351
|
-
|
|
1352
|
-
**Step 2.** Add a video tag to the `.html` file, then prepare and initialize `DocumentReaderProcessor`.
|
|
1353
|
-
|
|
1354
|
-
`DocumentReaderProcessor` is available in the global variable `window.Regula`. See the following example:
|
|
1355
|
-
|
|
1356
|
-
```javascript
|
|
1357
|
-
const { DocumentReaderProcessor } = window.Regula;
|
|
1358
|
-
|
|
1359
|
-
const videoElement = document.getElementById('yourVideoElement');
|
|
1360
|
-
const processor = new DocumentReaderProcessor(videoElement);
|
|
1361
|
-
|
|
1362
|
-
processor.recognizerProcessParam = {
|
|
1363
|
-
processParam: {
|
|
1364
|
-
scenario: 'MrzAndLocate',
|
|
1365
|
-
},
|
|
1366
|
-
};
|
|
1367
|
-
processor.imageProcessParam = {
|
|
1368
|
-
processParam: {
|
|
1369
|
-
scenario: 'MrzAndLocate',
|
|
1370
|
-
},
|
|
1371
|
-
};
|
|
1372
|
-
|
|
1373
|
-
try {
|
|
1374
|
-
// Variant 1 - for production environment
|
|
1375
|
-
await processor.initialize();
|
|
1376
|
-
|
|
1377
|
-
// Variant 2 - for test-only environment
|
|
1378
|
-
// await processor.initialize({ license: 'BASE64_LICENSE_KEY' });
|
|
1379
|
-
|
|
1380
|
-
const result = await processor.startRecognition(); // Result of the document recognition will be located here.
|
|
1381
|
-
|
|
1382
|
-
processor.stopRecognition();
|
|
1383
|
-
|
|
1384
|
-
console.log(result);
|
|
1385
|
-
} catch (e) {
|
|
1386
|
-
console.log(e);
|
|
1387
|
-
}
|
|
1388
|
-
```
|
|
1389
|
-
|
|
1390
|
-
In the preceding example, the `DocumentReaderProcessor` object is created using the HTML element with ID `yourVideoElement`.
|
|
1391
|
-
After that, `processor` needs to be initialized with the license. There are two licensing variants:
|
|
1392
|
-
|
|
1393
|
-
**1.** <a href="https://docs.regulaforensics.com/develop/doc-reader-sdk/overview/licensing">Domain name licensing</a> (for **production** environment).
|
|
1394
|
-
|
|
1395
|
-
To get your website domain licensed, <a href="https://explore.regula.app/docs-support-request" target="_blank">contact our sales team</a>.
|
|
1396
|
-
|
|
1397
|
-
Then asynchronously call the `initialize` method without parameters:
|
|
1398
|
-
```javascript
|
|
1399
|
-
await processor.initialize();
|
|
1400
|
-
```
|
|
1401
|
-
|
|
1402
|
-
**2.** Base64 license string (for **test-only** environment).
|
|
1403
|
-
|
|
1404
|
-
You need to convert Regula license file to the Base64 string and then asynchronously call `initialize` method, replacing `BASE64_LICENSE_KEY` with that encoded string:
|
|
1405
|
-
```javascript
|
|
1406
|
-
await processor.initialize({ license: 'BASE64_LICENSE_KEY' });
|
|
1407
|
-
```
|
|
1408
|
-
|
|
1409
|
-
For more information about licensing, see the <a href="https://docs.regulaforensics.com/develop/doc-reader-sdk/overview/licensing/" target="_blank">Document Reader SDK Licensing</a> page and the
|
|
1410
|
-
<a href="https://support.regulaforensics.com/hc/en-us/articles/15378060500881-How-to-convert-a-license-file-to-BASE64-" target="_blank">How to Convert a License File to BASE64</a> FAQ article.
|
|
1411
|
-
|
|
1412
|
-
### Processor Methods
|
|
1413
|
-
|
|
1414
|
-
#### initialize
|
|
1415
|
-
|
|
1416
|
-
Initializes the DocumentReaderProcessor object. Accepts an object with a Base64 encoded license string.
|
|
1417
|
-
|
|
1418
|
-
**Note:** Base64 license string is applied only to test environments, production mode must use the <a href="https://docs.regulaforensics.com/develop/doc-reader-sdk/overview/licensing">domain name licensing</a>.
|
|
1419
|
-
|
|
1420
|
-
```javascript
|
|
1421
|
-
await processor.initialize({ license: 'BASE64_LICENSE_KEY' });
|
|
1422
|
-
```
|
|
1423
|
-
|
|
1424
|
-
#### startRecognition
|
|
1425
|
-
|
|
1426
|
-
Launches the video stream and starts recognizing the document. Returns the result of document processing.
|
|
1427
|
-
|
|
1428
|
-
```javascript
|
|
1429
|
-
const result = await processor.startRecognition();
|
|
1430
|
-
```
|
|
1431
|
-
|
|
1432
|
-
`startRecognition` may take the callback function with the object parameter `currentPage` holding the data of the page currently being processed.
|
|
1433
|
-
The `currentpage` data fields include:
|
|
1434
|
-
|
|
1435
|
-
* `currentPage.data` object with an intermediate processing result
|
|
1436
|
-
* `currentPage.startNextPage` method for starting the next page procession
|
|
1437
|
-
* `currentPage.finishRecognition` method for completing the entire process
|
|
1438
|
-
|
|
1439
|
-
The next example demonstrates the case, when recognition of the next page is delayed by 3 seconds (3000 ms). During this time you may ask the user to turn the document over.
|
|
1440
|
-
|
|
1441
|
-
```javascript
|
|
1442
|
-
async function pageListener(currentPage) {
|
|
1443
|
-
|
|
1444
|
-
setTimeout(async () => {
|
|
1445
|
-
await currentPage.startNextPage();
|
|
1446
|
-
}, 3000);
|
|
1447
|
-
}
|
|
1448
|
-
|
|
1449
|
-
const result = await processor.startRecognition(pageListener);
|
|
1450
|
-
```
|
|
1451
|
-
|
|
1452
|
-
#### processImage
|
|
1453
|
-
|
|
1454
|
-
Processes the image files, containing documents. Can take as a parameter a `FileList` or `Blob` array:
|
|
1455
|
-
|
|
1456
|
-
```javascript
|
|
1457
|
-
const file = 'FileList or Blob array';
|
|
1458
|
-
|
|
1459
|
-
const result = await processor.processImage(file);
|
|
1460
|
-
```
|
|
1461
|
-
|
|
1462
|
-
**Note:** For more information about FileList and Blob types, see the links: <a href="https://developer.mozilla.org/en-US/docs/Web/API/FileList" target="_blank">FileList</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/API/Blob" target="_blank">Blob</a>.
|
|
1463
|
-
|
|
1464
|
-
#### switchCamera
|
|
1465
|
-
|
|
1466
|
-
Switches to the next camera (in case there are several available).
|
|
1467
|
-
|
|
1468
|
-
```javascript
|
|
1469
|
-
await processor.switchCamera();
|
|
1470
|
-
```
|
|
1471
|
-
|
|
1472
|
-
#### stopRecognition
|
|
1473
|
-
|
|
1474
|
-
Stops the document recognition process and ends the video stream.
|
|
1475
|
-
|
|
1476
|
-
```javascript
|
|
1477
|
-
processor.stopRecognition();
|
|
1478
|
-
```
|
|
1479
|
-
|
|
1480
|
-
### Processor Parameters
|
|
1481
|
-
|
|
1482
|
-
You can change the default settings for video streaming and document recognition.
|
|
1483
|
-
The settings must be set **before** the document recognition process starts.
|
|
1484
|
-
|
|
1485
|
-
#### streamParam
|
|
1486
|
-
|
|
1487
|
-
The video stream parameters.
|
|
1488
|
-
|
|
1489
|
-
```javascript
|
|
1490
|
-
processor.streamParam = {
|
|
1491
|
-
cameraMode: 'environment',
|
|
1492
|
-
preferredCameraId: '',
|
|
1493
|
-
resolution: {
|
|
1494
|
-
width: 1280,
|
|
1495
|
-
height: 720,
|
|
1496
|
-
},
|
|
1497
|
-
}
|
|
1498
|
-
```
|
|
1499
|
-
|
|
1500
|
-
Available streaming parameters:
|
|
1501
|
-
|
|
1502
|
-
* `cameraMode`
|
|
1503
|
-
Camera facing mode. Can have values of 'environment' (by default) or 'user'.
|
|
1504
|
-
* `preferredCameraId`
|
|
1505
|
-
ID of the concrete camera to be used for the streaming. Can be extracted from `navigator.mediaDevices.enumerateDevices()`. **Not** set by default.
|
|
1506
|
-
* `resolution`
|
|
1507
|
-
Resolution of a video stream. 1280 x 720 by default.
|
|
1508
|
-
|
|
1509
|
-
#### recognizerProcessParam
|
|
1510
|
-
|
|
1511
|
-
The parameters for recognizing a document from the camera (by the `startRecognition` method). See the following example with several parameters and their default values:
|
|
1512
|
-
|
|
1513
|
-
```javascript
|
|
1514
|
-
processor.recognizerProcessParam = {
|
|
1515
|
-
processParam: {
|
|
1516
|
-
returnUncroppedImage: true,
|
|
1517
|
-
returnPackageForReprocess: false,
|
|
1518
|
-
},
|
|
1519
|
-
};
|
|
1520
|
-
```
|
|
1521
|
-
|
|
1522
|
-
For more information, see the list of all available <a href="https://docs.regulaforensics.com/develop/doc-reader-sdk/web-service/development/usage/params/" target="_blank">document processing params</a>.
|
|
1523
|
-
|
|
1524
|
-
#### imageProcessParam
|
|
1525
|
-
|
|
1526
|
-
The settings for recognizing an image as a document file (by `processImage` method).
|
|
1527
|
-
See the following example with several parameters and their default values:
|
|
1528
|
-
|
|
1529
|
-
```javascript
|
|
1530
|
-
// Default settings:
|
|
1531
|
-
processor.imageProcessParam = {
|
|
1532
|
-
processParam: {
|
|
1533
|
-
returnUncroppedImage: true,
|
|
1534
|
-
returnPackageForReprocess: false,
|
|
1535
|
-
},
|
|
1536
|
-
}
|
|
1537
|
-
```
|
|
1538
|
-
|
|
1539
|
-
For more information, see the list of all available <a href="https://docs.regulaforensics.com/develop/doc-reader-sdk/web-service/development/usage/params/" target="_blank">document processing params</a>.
|
|
1540
|
-
|
|
1541
|
-
#### recognizeListener
|
|
1542
|
-
|
|
1543
|
-
The callback function that takes as a parameter the processing result for each frame (`response`).
|
|
1544
|
-
See the following example, where the processing result for each frame is logged to the console:
|
|
1545
|
-
|
|
1546
|
-
```javascript
|
|
1547
|
-
function listener(response) {
|
|
1548
|
-
console.log(response);
|
|
1549
|
-
}
|
|
1550
|
-
|
|
1551
|
-
processor.recognizeListener = listener;
|
|
1552
|
-
```
|
|
1553
|
-
|
|
1554
|
-
**Note:** The listener for image recognizer is **not** set by default.
|
|
1555
|
-
|
|
1556
|
-
#### videoElement
|
|
1557
|
-
|
|
1558
|
-
The HTML element to display the video stream from the camera.
|
|
1559
|
-
This setting changes the video element that was defined during processor object construction `new DocumentReaderProcessor(videoElement)`.
|
|
1560
|
-
See the example:
|
|
1561
|
-
|
|
1562
|
-
```javascript
|
|
1563
|
-
const videoElement = document.getElementById('HTMLVideoElement');
|
|
1564
|
-
|
|
1565
|
-
processor.videoElement = videoElement; // null by default
|
|
1566
|
-
```
|
|
1567
|
-
|
|
1568
|
-
By default, `processor.videoElement` has `null` value.
|
|
1569
|
-
|
|
1570
|
-
#### isInitialized
|
|
1571
|
-
|
|
1572
|
-
Read-only property. `true` if the processor has been initialized.
|
|
1573
|
-
|
|
1574
|
-
```javascript
|
|
1575
|
-
processor.isInitialized;
|
|
1576
|
-
```
|
|
1577
|
-
|
|
1578
|
-
#### isProcessing
|
|
1579
|
-
|
|
1580
|
-
Read-only property. `true` if document recognition is still in progress.
|
|
1581
|
-
|
|
1582
|
-
```javascript
|
|
1583
|
-
processor.isProcessing;
|
|
1584
|
-
```
|
|
1585
|
-
|
|
1586
|
-
## Package Resources
|
|
1587
|
-
|
|
1588
|
-
Document reader requires WASM (`ProcMgr.wasm`, `ProcMgr.data`) and worker (`ProcMgr.worker.js`) files to work.
|
|
1589
|
-
By default, these files are downloaded from Regula servers, but you can set your own source.
|
|
1590
|
-
|
|
1591
|
-
**1.** To download these files from our server to local machine, you can get the link in the `window.RegulaDocumentSDK.workerPath` field.
|
|
1592
|
-
|
|
1593
|
-
**2.** Upload all three files (`ProcMgr.worker.js`, `ProcMgr.wasm`, `ProcMgr.data`) to the location you specified. Also, change the address in `windows.RegulaDocumentSDK`.
|
|
1594
|
-
|
|
1595
|
-
For Predefined UI Components:
|
|
1596
|
-
|
|
1597
|
-
```javascript
|
|
1598
|
-
window.RegulaDocumentSDK.workerPath = 'https://custom-wasm-and-worker-files-path.com';
|
|
1599
|
-
```
|
|
1600
|
-
|
|
1601
|
-
For Document Reader Processor:
|
|
1602
|
-
|
|
1603
|
-
```javascript
|
|
1604
|
-
const processor = new DocumentReaderProcessor(videoElement);
|
|
1605
|
-
processor.workerPath = 'https://custom-wasm-and-worker-files-path.com';
|
|
1606
|
-
```
|
|
1607
|
-
|
|
1608
|
-
In the given examples, change the `workerPath` parameter value to your custom source URL.
|
|
1609
|
-
|
|
1610
|
-
**Attention!** The files must be located in the same directory and have the same names as were previously specified.
|
|
1611
|
-
|
|
1612
|
-
To decrease files size, you can apply compression. On your server, you need to determine which <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding" target="_blank">compression method</a> is used for the files.
|
|
1613
|
-
|
|
1614
|
-
## Potential Problems
|
|
1615
|
-
|
|
1616
|
-
UI components and SDK use the `getUserMedia` method to display the video stream from the camera. This feature is available only in secure contexts (HTTPS).
|
|
1617
|
-
|
|
1618
|
-
## Examples
|
|
1619
|
-
|
|
1620
|
-
You can see the examples of using the components on the [Samples page](https://github.com/regulaforensics/document-web-components-samples).
|
|
1621
|
-
|
|
1622
|
-
## Additional Resources
|
|
1623
|
-
|
|
1624
|
-
The Document Reader web components are also available on <a href="https://storybook-document.regulaforensics.com" target="_blank">Storybook</a>.
|
|
1625
|
-
|
|
1626
|
-
## FAQ
|
|
1627
|
-
|
|
1628
|
-
### How do I collect logs?
|
|
1629
|
-
|
|
1630
|
-
Logging can be helpful when you run into any issues.
|
|
1631
|
-
Logs contain information about how you use our products. That data helps Regula stuff to analyze and troubleshoot the cases you may experience.
|
|
1632
|
-
|
|
1633
|
-
There are two ways to output logs: console or function callback.
|
|
1634
|
-
|
|
1635
|
-
#### Console
|
|
1636
|
-
|
|
1637
|
-
To initiate the process of logs collecting:
|
|
1638
|
-
|
|
1639
|
-
**1.** Open the Developer menu in your browser.
|
|
1640
|
-
|
|
1641
|
-
**2.** Go to the Console tab.
|
|
1642
|
-
|
|
1643
|
-
**3.** In Console, enter the following line:
|
|
1644
|
-
|
|
1645
|
-
```console
|
|
1646
|
-
localStorage.logger = 'main,wasm>console'
|
|
1647
|
-
```
|
|
1648
|
-
|
|
1649
|
-
**4.** Reload the page.
|
|
1650
|
-
|
|
1651
|
-
**5.** Add the `log` setting to the `processParam` if you want to see logs from WASM:
|
|
1652
|
-
|
|
1653
|
-
```json
|
|
1654
|
-
{
|
|
1655
|
-
"processParam": {
|
|
1656
|
-
"log": true
|
|
1657
|
-
}
|
|
1658
|
-
}
|
|
1659
|
-
```
|
|
1660
|
-
|
|
1661
|
-
**6.** Start image processing. Logs will be displayed in Console.
|
|
1662
|
-
|
|
1663
|
-
#### Function callback
|
|
1664
|
-
|
|
1665
|
-
**1.** Import logging service from library.
|
|
1666
|
-
|
|
1667
|
-
```javascript
|
|
1668
|
-
import { Logger } from '@regulaforensics/vp-frontend-document-components';
|
|
1669
|
-
```
|
|
1670
|
-
|
|
1671
|
-
**2.** Set the callback function.
|
|
1672
|
-
|
|
1673
|
-
```javascript
|
|
1674
|
-
Logger.logListener = (log) => {
|
|
1675
|
-
// ...
|
|
1676
|
-
// do something with log
|
|
1677
|
-
// ...
|
|
1678
|
-
};
|
|
1679
|
-
```
|
|
1680
|
-
|
|
1681
|
-
**3.** Add the `log` setting to the `processParam` if you want to see logs from WASM:
|
|
1682
|
-
|
|
1683
|
-
```json
|
|
1684
|
-
{
|
|
1685
|
-
"processParam": {
|
|
1686
|
-
"log": true
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1689
|
-
```
|
|
160
|
+
To discuss business opportunities, fill the <a target="_blank" href="https://explore.regula.app/docs-support-request">Enquiry Form</a> and specify your scenarios, applications, and technical requirements.
|