capacitor-klippa-scanner-sdk
SDK License
Please be aware you need to have a license to use this SDK.
If you would like to use our scanner, please contact us here
Getting started
Android
Edit the file android/key.properties
, if it doesn't exist yet, create it. Add the SDK credentials:
klippa.scanner.sdk.username={your-username}
klippa.scanner.sdk.password={your-password}
Replace the {your-username}
and {your-password}
values with the ones provided by Klippa.
iOS
Edit the file ios/Podfile
, add the Klippa CocoaPod:
// Edit the platform to a minimum of 13.0, our SDK doesn't support earlier iOS versions.
platform :ios, '13.0'
target 'YourApplicationName' do
# Pods for YourApplicationName
// ... other pods
pod 'Klippa-Scanner', podspec: 'https://custom-ocr.klippa.com/sdk/ios/specrepo/{your-username}/{your-password}/KlippaScanner/latest.podspec'
end
Replace the {your-username}
and {your-password}
values with the ones provided by Klippa.
Edit the file ios/{project-name}/Info.plist
and add the NSCameraUsageDescription
value:
...
<key>NSCameraUsageDescription</key>
<string>Access to your camera is needed to photograph documents.</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Access to your photo library is used to save the images of documents.</string>
...
Ionic
npm install @klippa/capacitor-klippa-scanner-sdk
npx cap sync
Don't forget to run pod install
in the ios folder when running the iOS app.
Usage
Import & Configuration
import { KlippaScannerSDK } from "@klippa/capacitor-klippa-scanner-sdk"
const KlippaScannerConfig: CameraConfig = {
license: "your-license",
allowMultipleDocuments: false,
defaultMultipleDocuments: false,
shutterButton: { allowShutterButton: true, hideShutterButton: false },
defaultCrop: false,
imageMaxWidth: 1920,
imageMaxHeight: 1080,
imageMaxQuality: 95,
deleteButtonText: "Delete",
retakeButtonText: "Retake",
cancelButtonText: "Cancel",
cancelConfirmationMessage: "Are you sure you want to cancel?",
cancelAndDeleteImagesButtonText: "Delete images",
cameraModeSingle: { name: "Single", message: "Instructions" },
cameraModeMulti: { name: "Multi", message: "Instructions" },
cameraModeSegmented: { name: "Segmented", message: "Instructions" },
startingIndex: 0,
defaultColor: 'enhanced',
imageMovingSensitivityAndroid: 50,
userCanRotateImage: true,
userCanCropManually: true,
userCanChangeColorSetting: true,
primaryColor: '#52277c',
accentColor: '#52277c',
overlayColor: '#52277c',
warningBackgroundColor: '#fff',
warningTextColor: '#52277c',
imageLimit: 5,
iconEnabledColor: '#9B3BF9',
iconDisabledColor: '#bab9bd',
reviewIconColor: '#fff',
overlayColorAlpha: 0.75,
previewDuration: 1.0,
isViewFinderEnabled: true,
timer: { allowed: false, enabled: false, duration: 0.4 },
cropPadding: { width: 100, height: 100 },
success: { message: 'Success', previewDuration: 1 },
storeImagesToCameraRoll: false,
imageMovingSensitivityIOS: 200,
}
Starting the scanner
The result of KlippaScannerSDK.getCameraResult(config: CameraConfig)
is a Promise, so you can get the result with:
KlippaScannerSDK.getCameraResult(KlippaScannerConfig).then((result) => {
console.log(`Took ${result.images.length} pictures`);
}).catch((reason) => {
console.log(reason)
})
The content of the result object is:
{
"multipleDocuments": true,
"crop": true,
"color": "original",
"images": [
{
"filePath": "example/path/to/your/image.jpg"
}
]
}
The reject reason object has a code and a message, the used codes are:
- E_LICENSE_ERROR
- E_CANCELED
- E_UNKNOWN_ERROR
How to use a specific version of the SDK?
Android
Edit the file android/build.gradle
, add the following:
allprojects {
// ... other definitions
project.ext {
klippaScannerVersion = "{version}"
}
}
Replace the {version}
value with the version you want to use.
iOS
Edit the file ios/Podfile
, change the pod line of Klippa-Scanner
and replace latest.podspec
with {version}.podspec
, replace the {version}
value with the version you want to use.
How to change the colors of the scanner?
Android
Add or edit the file android/app/src/main/res/values/colors.xml
, add the following:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="klippa_scanner_sdk_color_Primary">#2dc36a</color>
<color name="klippa_scanner_sdk_color_PrimaryDark">#308D53</color>
<color name="klippa_scanner_sdk_color_Accent">#2dc36a</color>
<color name="klippa_scanner_sdk_color_Overlay">#2dc36a</color>
<color name="klippa_scanner_sdk_color_Warning">#BFFF0000</color>
<color name="klippa_scanner_sdk_color_IconDisabledColor">#80FFFFFF</color>
<color name="klippa_scanner_sdk_color_IconEnabledColor">#FFFFFFFF</color>
<color name="klippa_scanner_sdk_color_ReviewIconColor">#FFFFFFFF</color>
</resources>
iOS
Use the following properties in the config when running getCameraResult
: primaryColor
, accentColor
, overlayColor
, warningBackgroundColor
, warningTextColor
, overlayColorAlpha
, iconDisabledColor
, iconEnabledColor
, reviewIconColor
.
How to change the texts in the scanner?
Android
Use the following properties in the config when running getCameraResult
: deleteButtonText
, retakeButtonText
, cancelButtonText
, cancelAndDeleteImagesButtonText
, cancelConfirmationMessage
, moveCloserMessage
, imageMovingMessage
, imageLimitReachedMessage
, orientationWarningMessage
.
or
Add or edit the file android/app/src/main/res/values/strings.xml
, add the following:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="klippa_zoom_message">Move closer to the document</string>
<string name="klippa_image_limit_reached">You have reached the image limit</string>
<string name="klippa_success_message">Success</string>
<string name="klippa_image_moving_message">Moving too much</string>
<string name="klippa_orientation_warning_message">Hold your phone in portrait mode</string>
<string name="klippa_delete_button_text">Delete Photo</string>
<string name="klippa_retake_button_text">Retake Photo</string>
<string name="klippa_cancel_button_text">Cancel</string>
<string name="klippa_cancel_delete_images">Delete photos and exit</string>
<string name="klippa_cancel_confirmation">Delete photos and exit scanner?</string>
</resources>
iOS
Use the following properties in the config when running getCameraResult
: imageTooBrightMessage
, imageTooDarkMessage
, deleteButtonText
, retakeButtonText
, cancelButtonText
, cancelAndDeleteImagesButtonText
, cancelConfirmationMessage
, moveCloserMessage
, imageMovingMessage
, imageLimitReachedMessage
, orientationWarningMessage
, imageColorOriginalText
, imageColorGrayScaleText
, imageColorEnhancedText
.
Important iOS notes
Older iOS versions do not ship the Swift libraries. To make sure the SDK works on older iOS versions, you can configure the build to embed the Swift libraries using the build setting EMBEDDED_CONTENT_CONTAINS_SWIFT = YES
.
We started using XCFrameworks from version 0.1.0, if you want to use that version or up, you need CocoaPod version 1.9.0 or higher.
Important Android notes
When using a custom trained model for object detection, add the following to your app's build.gradle file to ensure Gradle doesn’t compress the models when building the app:
android {
aaptOptions {
noCompress "tflite"
}
}
Using the Example App
- Clone the project
- Run
npm install
in both root
and example
folders. - Run
npm run build
in both root
and example
folders. - Run
npx cap sync
in example folder. - Run
npx cap run ios
or npx cap run android
for whichever OS you want to run on.
Note: You will need to add your own Klippa username and password to the Podfile
and build.gradle
to pull the dependencies correctly.
You might also need to run pod install
in example/ios/App/ folder.
About Klippa
Klippa is a scale-up from Groningen, The Netherlands and was founded in 2015 by six Dutch IT specialists with the goal to digitize paper processes with modern technologies.
We help clients enhance the effectiveness of their organization by using machine learning and OCR. Since 2015 more than a 1000 happy clients have been served with a variety of the software solutions that Klippa offers. Our passion is to help our clients to digitize paper processes by using smart apps, accounts payable software and data extraction by using OCR.
License
The MIT License (MIT)