Skip to main content

The QiTechWebOCR.WebOCR() constructor

New in version 4.0.0

Starting from version 4.0.0, the constructor no longer receives htmlComponent as the first parameter — the SDK creates and manages its own DOM node internally, appended to document.body.

The .WebOCR() method is responsible for configuring the instance of your documentoscopy component. The constructor receives two mandatory parameters:

ParameterDescriptionRequired
webTokenClient key that identifies that the collected data comes from your application. If you have not yet received your web-token, contact support.Yes
sessionIdUsed to define the key that identifies the session started in the SDK. It is used to track the entire flow traversed by the user in the Web OCR execution through logs. This field accepts a string of up to 255 characters. Must be unique for each session.Yes

After instantiation, use the following chained methods to customize behavior:

NameDescriptionRequired
.setThemeConfiguration(object)Customizes the visual identity of the SDK.No
.setShowInstructionScreen(boolean)Displays the introduction screen with capture tips. Default: true.No
.setShowAllowedTemplatesScreen(boolean)Displays the screen informing which documents are accepted. We recommend enabling it so the user knows which documents they can submit.No
.setShowSuccessScreen(boolean)Displays the success screen at the end of the capture. Default: true.No
.setSandboxEnvironment()Configures the SDK to point to the Sandbox environment.No

The .setThemeConfiguration method must receive an object with the following fields:

NameTypeDescription
primaryColorString(recommended) Hexadecimal of the SDK's primary color — used in buttons, icons, and highlights. Default: #555555.
companyLogoString(recommended) Path or public URL of your company logo (PNG). If not provided, a placeholder will be displayed.
fontFamilyString(recommended) Font Family to be applied to SDK texts. If not provided, the default font will be used.
Compatibility

The backgroundColor and buttonColor fields are still accepted by .setThemeConfiguration, but are only used as a fallback to derive primaryColor when it is not provided. Prefer using primaryColor directly.

Previous Versions (< 4.0.0)

In previous versions, the constructor received htmlComponent as the first parameter:

var htmlComponent = document.getElementById('webOCR');
var webOCR = new QiTechWebOCR.WebOCR(
htmlComponent,
"<WEB_TOKEN>",
"<SESSION_ID>"
)