@regulaforensics/document-reader-client v5.2.0-beta.5
Regula Document Reader js client for the browser and node.js based on axios
Documents recognition as easy as reading two bytes.
If you have any problems with or questions about this client, please contact us through a GitHub issue. You are invited to contribute new features, fixes, or updates, large or small; We are always thrilled to receive pull requests, and do our best to process them as fast as we can.
Install package
npm install @regulaforensics/document-reader-client
Example
Performing request:
import {DocumentReaderApi, FieldType, GraphicFieldType} from '@regulaforensics/document-reader-client/esm'
const {DOCUMENT_NUMBER, SURNAME_AND_GIVEN_NAMES, DATE_OF_BIRTH} = FieldType;
const {PORTRAIT, SIGNATURE} = GraphicFieldType;
const imageAsBase64String = getDocImageAsBase64String()
const api = new DocumentReaderApi({basePath: "http://localhost:8080"});
const result = await api.process(imageAsBase64String)
Parsing results:
// text fields
const docNumber = result.getTextField(DOCUMENT_NUMBER)
const fullName = result.getTextField(SURNAME_AND_GIVEN_NAMES)
const dateOfBirth = result.getTextField(DATE_OF_BIRTH)
// graphics fields
const portraitAsBase64 = result.getGraphicsField(PORTRAIT)
const signatureAsBase64 = result.getGraphicsField(SIGNATURE)
Compatibility
Language level
- ES5, ES6.Promises - depends on a native ES6 Promise implementation to be supported. If your environment doesn't support ES6 Promises, you can polyfill.
Module system
- CommonJS
- ES6 module system
Definitions
- TypeScript's definitions should be automatically resolved via
package.json
. (Reference)
Development
Js client is written using typescript, mainly generated from openapi spec.
Openapi-generator output used as implementation base(see packages /src/api
, /scr/models
).
All custom logic, on top of generated files, should be places in /src/ext
folder.
To regenerate models from openapi definition,
clone latest open api definitions
and set DEFINITION_FOLDER
as path to cloned directory, for example:
DEFINITION_FOLDER="/home/user/projects/DocumentReader-api-openapi"
Then use next command from the project root:
docker run --rm -v "${PWD}:/client" -v "${DEFINITION_FOLDER}:/definitions" \
openapitools/openapi-generator-cli generate -g typescript-axios \
-i /definitions/index.yml -o /client/src -c /client/ts-generator-config.json \
-t /client/generator-templates/
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago