Skip to main content

Collecting Returns

The Web OCR SDK returns a Promise that, in case of success, returns an array of objects, where each object represents a side of the captured document (front and/or back). In case of error, the Promise is rejected with a string describing the problem.

Below is an example of how to map each case and collect its results:

<script>
webOCR.initialize(allowed_templates)
.then((ocr_results) => {
console.log(ocr_results)
// Example return:
// [
// { template: "rg_front", ocr_key: "abc123...", document_capture_session_key: "uuid..." },
// { template: "rg_back", ocr_key: "def456...", document_capture_session_key: "uuid..." }
// ]
})
.catch((error) => {
console.log(error)
})
</script>

Web OCR Return Description

Success

The success return is an array of objects, one per captured document side:

AttributeTypeDescription
ocr_resultsArrayList of objects with information about each capture performed.

Attributes of each object in the array

AttributeTypeDescription
ocr_keyStringIdentification key of the captured image. Can be used in any other QI Tech system service.
templateStringType and side of the captured document (e.g.: rg_front, rg_back, cnh_front, cnh_back, cin_digital).
document_capture_session_keyStringKey that identifies the document capture session.

Error Types

ErrorDescription
Invalid Web Token! Please verify your Web Token.Web Token used is invalid. If you are certain that you are correctly using the Web Token provided by QI Tech, contact our support (suporte.caas@qitech.com.br).
Invalid Document Type! Please provide a valid document type.Document type passed to WebOCR.initialize() is not valid. Check the allowed types on the initialize function page.
User left Web OCR.The user exited the Web OCR SDK before completing the document submission.