### Setup Project Dependencies and Build Source: https://github.com/regulaforensics/documentreader-web-js-client/blob/develop/examples/basic/README.md These commands install the necessary Node.js packages for the main project, build the client, then change into the 'example' directory and install its specific dependencies, preparing the example for execution. ```bash npm install npm run build cd example npm install ``` -------------------------------- ### Run Client with Demo Regula Document Reader API Source: https://github.com/regulaforensics/documentreader-web-js-client/blob/develop/examples/basic/README.md This command executes the JavaScript example application using Node.js, connecting to the default demo Regula Document Reader web API. It should be run from within the 'example' directory. ```bash node . ``` -------------------------------- ### Verify Node.js and npm Versions Source: https://github.com/regulaforensics/documentreader-web-js-client/blob/develop/examples/basic/README.md This snippet shows how to check the installed versions of Node.js and npm from the command line to ensure they meet the project's requirements (Node.js 12+, npm 6+). ```bash node --version npm --version ``` -------------------------------- ### Clone Regula Document Reader JS Client Repository Source: https://github.com/regulaforensics/documentreader-web-js-client/blob/develop/examples/basic/README.md This command sequence clones the official Regula Document Reader JavaScript client repository from GitHub and navigates into the newly created project directory, preparing for dependency installation. ```bash git clone https://github.com/regulaforensics/DocumentReader-web-js-client.git cd DocumentReader-web-js-client ``` -------------------------------- ### Run Client with Local Regula Document Reader API Source: https://github.com/regulaforensics/documentreader-web-js-client/blob/develop/examples/basic/README.md This command runs the JavaScript example application, explicitly setting the 'API_BASE_PATH' environment variable to connect to a locally running Regula Document Reader web API instance. This is used when a custom API endpoint is preferred over the demo service. ```bash API_BASE_PATH="http://127.0.0.1:8080" node . ``` -------------------------------- ### Example Output of Document Reader Client Source: https://github.com/regulaforensics/documentreader-web-js-client/blob/develop/examples/basic/README.md This text snippet illustrates the typical console output generated by the Regula Document Reader client, showing extracted document fields like surname, given names, and document status, along with their sources and values. ```text --------------------------------------------------------------- Document name: Germany - ePassport (2017) Service --------------------------------------------------------------- [Surname] - Source: VISUAL Value : MUSTERMANN --------------------------------------------------------------- [Surname And Given Names] - Source: VISUAL Value : MUSTERMANN ERIKA --------------------------------------------------------------- [Document Status] - Source: MRZ Value : SPECIMEN - Source: VISUAL Value : SPECIMEN ... ``` -------------------------------- ### Install Regula Document Reader JS Client Source: https://github.com/regulaforensics/documentreader-web-js-client/blob/develop/README.md This command installs the Regula Document Reader web client package using npm. It's the first step to integrate the client into your JavaScript or Node.js project, providing access to its functionalities for document processing. ```npm npm install @regulaforensics/document-reader-webclient ``` -------------------------------- ### Regenerate OpenAPI Models with Bash Script Source: https://github.com/regulaforensics/documentreader-web-js-client/blob/develop/dev.md This bash command executes a script to regenerate client models from the OpenAPI definition. It assumes the `DocumentReader-api-openapi` repository is cloned and the script is located in the project root. This process ensures the client models are up-to-date with the latest API specification. ```bash ./update-models.sh ``` -------------------------------- ### Perform Document Recognition Request with Regula JS Client Source: https://github.com/regulaforensics/documentreader-web-js-client/blob/develop/README.md This JavaScript snippet demonstrates how to initialize the `DocumentReaderApi` and send an image for processing. It imports necessary types like `Scenario` and field types, sets up the API base path, and performs an asynchronous `process` call with a base64 encoded image and a full processing scenario. ```JavaScript import { DocumentReaderApi, Scenario, TextFieldType, GraphicFieldType } from '@regulaforensics/document-reader-webclient'; const { DOCUMENT_NUMBER, SURNAME_AND_GIVEN_NAMES, DATE_OF_BIRTH } = TextFieldType; const { PORTRAIT, SIGNATURE } = GraphicFieldType; const imageAsBase64String = getDocImageAsBase64String(); const api = new DocumentReaderApi({ basePath: 'http://localhost:8080' }); const result = await api.process({ images: [documentImage], processParam: { scenario: Scenario.FULL_PROCESS} }); ``` -------------------------------- ### Parse Document Recognition Results in JavaScript Source: https://github.com/regulaforensics/documentreader-web-js-client/blob/develop/README.md This JavaScript code illustrates how to extract specific text and graphic fields from the `result` object returned by the document recognition API. It demonstrates accessing fields like document number, full name, date of birth, portrait, and signature using predefined `TextFieldType` and `GraphicFieldType` enums. ```JavaScript // text fields const docNumber = result.text?.getField(DOCUMENT_NUMBER); const fullName = result.text?.getField(SURNAME_AND_GIVEN_NAMES); const dateOfBirth = result.text?.getField(DATE_OF_BIRTH); // graphics fields const portraitAsBase64 = result.images?.getField(PORTRAIT); const signatureAsBase64 = result.images?.getField(SIGNATURE); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.