DocumentReaderProcessor methods
prepare
Prepares SDK files. The method must be run before initialization:
await processor.prepare();
initialize
Initializes the processor. The method must be run after preparing. Accepts an object with a base64 license. An object with a license must be installed only to work on test environments. Do not install an object with a license in production mode:
await processor.initialize({license: 'BASE64_LICENSE_KEY'});
startRecognition
The method starts the video stream and starts the process of recognizing the document. Returns the result of document processing:
const result = await processor.startRecognition();
To process multi-page documents, add the callback function to the method. The callback function takes in an object with an intermediate result of processing, a method for starting the next page and a method for completing the process:
/**
* @param {object} currentPage - Page data.
* @param {object} currentPage.data - Page processing result.
* @param {function} currentPage.startNextPage - The method of starting the recognition of the next page.
* @param {function} currentPage.finishRecognition - Finish the process and return the result.
*/
async function pageListener(currentPage) {
setTimeout(async () => {
await currentPage.startNextPage(); // Will start recognition of the next page in 3 seconds.
}, 3000); // During this time, you can tell the user to turn the document over.
}
const result = await processor.startRecognition(pageListener);
processImage
Processes document files. Can process FileList
or Blob
array:
const file = 'FileList or Blob array';
const result = await processor.processImage(file);
stopRecognition
Stops the document recognition process and ends the video stream.
processor.stopRecognition();