Simple scanner guide

Introduction

This guide explains how to build a simple scan flow with two lines of code. It demonstrates how to use each platform’s UI module to start a document capture, which allows the user to scan a multipage document and generate a PDF document

The scan flow consists of 3 screens that enable the user to capture and validate each page of its document:

  • a camera screen
  • a screen where the user can validate and adjust the borders of its document
  • a post-processing screen allowing the user to apply filters or to rotate the current page

Camera screen

Edit border screen

Post-processing screen

If you use a cross-platform framework such as ReactNative or Flutter, you can find additional details in the plugins’ documentation.

Setup

iOS

Include the ScannerUI and the Core subspecs in your Podfile:

pod 'GSSDK/Core', :podspec => 'https://s3.amazonaws.com/tgl.geniusscan.sdk/GSSDK-3.0.27.podspec'
pod 'GSSDK/ScannerUI', :podspec => 'https://s3.amazonaws.com/tgl.geniusscan.sdk/GSSDK-3.0.27.podspec'

See the iOS integration guide for more details.

Android

Add the following code to your app’s build.gradle:

repositories {
   ...
   maven { url 'https://s3.amazonaws.com/tgl.maven' }
}

dependencies {
  ...
  implementation 'com.thegrizzlylabs.geniusscan.sdk:gs-sdk-ui:3.0.27'
}

Licensing

The Genius Scan SDK is subject to a commercial license: a license key is needed to initialize the SDK. The key contains your application identifier (aka. bundle ID) and the license’s expiration date. Please contact us if you don’t have a license key yet.

If the key is invalid or your license is expired, the initialization will fail, and the SDK will not work. A good practice is to check if the initialization succeeds; if not, you can take an appropriate workaround (e.g.: disable the feature, prompt the user to update the application).

iOS

if (![GSK initWithLicenseKey:@"<YOUR LICENSE KEY>"]) {
   // The license is expired or invalid
}

Android

try {
   GeniusScanLibrary.init(getApplicationContext(), "<YOUR LICENSE KEY>");
} catch (RuntimeException e) {
   // The license is expired or invalid
}

Start the scan flow

You can configure the scan flow to capture a single page or several pages in a row. You configure the scan flow with several parameters such as:

  • Source: capture from the camera or import an existing image from the device’s photo library
  • Multipage mode: can be enabled or disabled
  • Background and text colors of the different screens
  • PDF page size and resolution
  • Camera flash mode
  • Available actions in the post-processing screen

Once the user is done scanning its pages, the scan flow returns the list of scanned pages as images and a PDF file combining all the pages.

iOS (Objective-C)

GSKScannerUIConfiguration *configuration = [GSKScannerUIConfiguration new];
configuration.multiPage = YES;
GSKScannerUI* scanner = [GSKScannerUI scannerUIWithConfiguration:configuration];
[scanner startFromViewController:root onSuccess:^(GSKScannerUIResult * _Nonnull result) {
    // Handle result
} failure:^(NSError *error) {
    // Handle error
}];

iOS (Swift)

let configuration = GSKScannerUIConfiguration()
configuration.multiPage = true
scanner = GSKScannerUI(configuration: configuration)
scanner.start(from: viewController, onSuccess: { result in
    // Handle result
}, failure: { error in
    // Handle error
})

Android

ScanConfiguration scanConfiguration = new ScanConfiguration();
scanConfiguration.multiPage = true;
GeniusScanSdkUI.scanWithConfiguration(context, scanConfiguration);

Products

Industries

Integration

Company

© 2023 The Grizzly Labs. All rights reserved.