Skip to main content

Text Data Scanner | Capacitor Document Scanner

The Text Data Scanner is a generic text recognizer and provides the ability to scan small text blocks with 1-2 lines in real-time. It is based on the OCR engine of Scanbot SDK. The UI contains a configurable finder (frame) within which the text to be scanned can be captured.

Typical use cases for the Data Scanner are the recognition of single-line text modules like IBAN numbers, insurance numbers, phone numbers, dates, and other simple textual data fields.

Furthermore, a special configuration of the Data Scanner allows scanning digits and characters from LC Dot-Matrix Displays.

alt text

Integrating the Data Scanner UI

The Data Scanner is based on the OCR feature and thus requires the proper installation of the corresponding OCR language files (e.g. for English please add the file eng.traineddata). For more details on how to set up OCR language files please refer to the OCR section.

Use the plugin API method ScanbotSDK.startTextDataScanner() to start the Data Scanner UI.

Start a scanner for an arbitrary text:

import { ScanbotSDK, TextDataScannerConfiguration } from 'capacitor-plugin-scanbot-sdk';
// Always make sure you have a valid license on runtime via ScanbotSDK.getLicenseInfo()
if (!licenseCheckMethod()) { return; }

const configuration: TextDataScannerConfiguration = {
textDataScannerStep: {
allowedSymbols: '',
aspectRatio: {
height: 1.0,
width: 5.0,
guidanceText: 'Place the text in the frame to scan it',
pattern: '',
preferredZoom: 2.0,
shouldMatchSubstring: false,
significantShakeDelay: -1,
textFilterStrategy: 'Document',
unzoomedFinderHeight: 40,
// Other UI configs...

const result = await ScanbotSDK.startTextDataScanner(configuration);

if (result.status === 'CANCELED') { return; }

// Handle the extracted data
// result.result.text...

Handling the Result

The result object contains the following fields:

  • status: 'OK' if data was extracted, 'CANCELED' if the user canceled the operation (tapped on the "cancel" button).
  • result:
    • text: Extracted text value.
    • confidence: Confidence in the accuracy of text


The UI and the behavior of the Data Scanner can be customized by passing the configs value via DataScannerConfiguration and TextDataScannerStep. All configuration options are optional.

export interface TextDataScannerConfiguration {
/** The preferred camera module (default - BACK) */
cameraModule?: CameraModule;

/** Background color outside of the finder window. */
cameraOverlayColor?: string;

/** Title of the cancel button. */
cancelButtonTitle?: string;

/** Whether the cancel button is hidden or not. iOS only. */
cancelButtonHidden?: boolean;

/** Title of the button that opens the screen where the user can allow the usage of the camera by the app. */
enableCameraButtonTitle?: string;

/** Text that will be displayed when the app is not allowed to use the camera, prompting the user to enable the usage of the camera. */
enableCameraExplanationText?: string;

/** Foreground color of the detection overlay. */
finderLineColor?: string;

/** Width of finder frame border. Default is 2. */
finderLineWidth?: number;

/** Foreground color of the description label. */
finderTextHintColor?: string;

/** Controls whether the flash toggle button is hidden or not. iOS only. */
flashButtonHidden?: boolean;

/** Title of the flash toggle button. iOS only. */
flashButtonTitle?: string;

/** Controls whether the flash should be initially enabled. The default value is FALSE. */
flashEnabled?: boolean;

/** UI Interface orientation lock mode */
orientationLockMode?: OrientationLockMode;

/** The background color of the top toolbar. */
topBarBackgroundColor?: string;

/** The color of all active toggle buttons in the toolbar. */
topBarButtonsActiveColor?: string;

/** The color of all inactive toggle buttons in the toolbar. */
topBarButtonsInactiveColor?: string;

/** The color of the highlight of the wordboxes founded on the frame */
wordBoxHighlightColor?: string;

/** If the wordboxes should be highlighted when were found on the frame */
wordBoxHighlightEnabled?: boolean;

/** Minimum number of accumulated frames that have equal result */
minimumNumberOfRequiredFramesWithEqualRecognitionResult?: number;

/** Maximum number of accumulated frames to inspect before actual result is returned */
maximumNumberOfAccumulatedFrames?: number;

/** The image will be downscaled to the given value during the processing. If the quality of the scanning is not enough, try to increase the limit. This variable affects the performance of the scanning process. Higher the size limit - better the quality, but the recognition is slower. 0 - do not rescale. */
ocrResolutionLimit?: number;

/** Controls whether buttons should use all capitals style, as defined by the Android Material Design. Defaults to TRUE. Android only. */
useButtonsAllCaps?: boolean;

/** If `true`, replaces the cancel button in the top bar with a back arrow icon. The default value is FALSE. Android only. */
replaceCancelButtonWithIcon?: boolean;

/** Preview mode of the camera. FILL_IN or FIT_IN. Default is FILL_IN. Android only */
cameraPreviewMode?: CameraPreviewMode;

/** Whether touch-to-focus is enabled on camera preview. Enabled by default. Android only. */
touchToFocusEnabled?: boolean;

/** Configuration for the scanned item */
textDataScannerStep?: TextDataScannerStep;

/** Filter text data by regular expression */
textDataValueFilter?: string
export interface TextDataScannerStep {
/** User guidance hint text. */
guidanceText: string;

/** Validation pattern to automatically validate recognized text. '?' = any character, '#' - any digit, all other characters represent themselves. An empty string or nil value will disable the validation pattern. */
pattern: string;

/** If set to TRUE pattern validation also validates successfully if only a part of the whole recognized text matches the the validation pattern. If set to FALSE, the whole text must match the validation pattern. Applies to pattern validation only. Defaults to FALSE. */
shouldMatchSubstring: boolean;

/** The cameras zoom level preferred for this step. The actual zoom might be different from the preferred one to avoid clipping of finder area and maintain its aspect ratio and height */
preferredZoom: number;

/** The cameras zoom level preferred for this step. The actual zoom might be different from the preferred one to avoid clipping of finder area and maintain its aspect ratio and height */
aspectRatio: AspectRatio;

/** The preferred height of the finder for zoom scale 1.0 (unzoomed). The actual finder height might change to maintain aspect ratio and to not clip the screen. Defaults to 40 points. */
unzoomedFinderHeight: number;

/** A string (list) of accepted characters during text recognition. If empty or nil, all characters are accepted. Defaults to nil. */
allowedSymbols: string;

/** Threshold used to pause the detection after significant movement occurred. Default = 0 */
significantShakeDelay: number;

Want to scan longer than one minute?

Generate a free trial license to test the Scanbot SDK thoroughly.

Get your free Trial License

What do you think of this documentation?