Deprecation warning
Please note that this is outdated documentation for an older release of the Scandit Barcode Scanner SDK.
We are deprecating the 5.x API on all platforms (except Linux). Release 5.19 in April 2021 will be our final. Applications running 5.x will continue to work, and we will continue to release critical bug fixes and security patches only, for one year. We encourage you to migrate to 6.x and take advantage of our latest / advanced features and improved performance.
You'll find the updated documentation at: Data Capture SDK Documentation for React Native
Motivation
OCR (Optical Character Recognition) enables text recognition for your mobile scanning apps. This means you can add text recognition to your organization’s mobile data capture workflows. As a result, you can seamlessly switch between reading barcodes and text with the touch of a button.
License Key
A dedicated OCR License key and SDK should be used. Please contact us (https://support.scandit.com/hc/en-us/requests/new) for more details.
Add Android dependency
- Copy a file named ScanditOCR.aar from the archive downloaded from your Scandit Barcode Scanner SDK account at http://account.scandit.com to <directory_of_your_project>/android/libs directory.
- Make sure your main build.gradle file contains the path to that directory (you might have already done it if you carefully followed the Integrate the Scandit SDK into your app) guide:
- Add the following dependency to your app's build.gradle to make sure the ScanditOCR library is accessible to use:
Add iOS dependency
- Copy ScanditOCR.bundle from the archive downloaded from your Scandit Barcode Scanner SDK account at http://account.scandit.com to the <directory_of_your_project>/ios/ScanditSDK directory.
- Open Xcode and drag and drop ScanditOCR.bundle inside the Frameworks folder (in the dialog, choose not to copy items).
Implementing OCR
To integrate the OCR into your react-native app, follow the simple steps below:
- Create a ScanSettings instance and set the recognition mode to Text (or to Code and Text if you want to read text and scan barcodes at the same time):
- Create a TextRecognitionSettings instance, assign it to the settings from the previous step and adjust it according to your OCR requirements:
- Make use of the BarcodePicker.onTextRecognized prop to handle recognized text according to your needs: