Simple integration with ScanFlow

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

  • a live preview screen to scan the document
  • a review screen where the user validates the scanned file and can optionally adjust the crop area or the filters.

If the multi-page mode is enabled, the user will repeat this interaction until they validate their batch of scan in the camera screen:

The live preview, the review screen, and the recrop screen.

In this guide, you will learn how to integrate this simple scan flow with a few lines of code.

Prerequisites

This guide assumes that you have followed the Getting Started guide :

  • You have integrated GSSDK.xcframework in your app.
  • You have initialized the SDK with the license key.
  • You have configured your app to request proper user permissions.

Start the scan flow

You configure the scan flow with a GSKScanFlowConfiguration object, which let you configure features such as:

  • Source: capture from the camera or import an existing image from the device’s photo library
  • Camera flash mode: you can force the flash to be always on, or only enable it on demand.
  • Multi-page mode: can be enabled or disabled.
  • PDF page size and resolution.
  • Available actions in the post-processing screen.
  • Background and text colors of the different screens.
  • Structured data extraction.

The API documentation documents all these parameters extensively.

Once the user finishes their scan session, the scan flow returns the list of the scanned pages as images and a PDF file combining all the pages.

Note: make sure you keep a strong reference to the GSKScanFlow.

let configuration = GSKScanFlowConfiguration()
configuration.multiPage = true
// Keep a strong reference on ScanFlow
self.scanFlow = GSKScanFlow(configuration: configuration)
scanFlow.start(from: viewController, onSuccess: { result in
    // Handle result
}, failure: { error in
    // Handle error
})

and… that’s it!

Handle the result of the scan flow

An implicit API contract is that you have to take ownership of the resulting files referenced by the GSKScanFlowResult object. You are responsible for moving them to the appropriate place and deleting them if you don’t need them anymore.

Example

The Simple Demo shows how to use the scan flow.

© 2024 The Grizzly Labs. All rights reserved.