Skip to content

Document Processing on Web Service

To get the maximum performance and ease the document processing on a mobile side, you can perform the document processing on the Document Reader Web API.

graph LR
  A(Mobile SDK) --->|Request| B(Web API Service);
  B --->|Response| A;

The benefits are:

  • The document processing is passed faster.
  • The size of the mobile application becomes as little as nothing.

Usage

Select Processing Mode

Before setting up, you need to specify the processing mode for the Mobile SDK. There two modes available: RGLOnlineProcessingModeManual and RGLOnlineProcessingModeAuto.

RGLOnlineProcessingModeManual

In this mode, the document processing is performed fully on the Web API service, while the Mobile SDK is used only for capturing document images and passing them to the service.

  • The processing is performed fully on the backend.
  • No need to add the Core framework.
  • No need to add the database.
  • No need to perform the initialization process.

RGLOnlineProcessingModeAuto

In this mode, the document processing is performed both on the mobile side and on the Web API service.

Set Up

Pass the chosen processing mode to the configuration object:

let config = DocReader.OnlineProcessingConfig(mode: .manual)
DocReader.shared.functionality.onlineProcessingConfig = config

By default, the FullProcess scenario is used to process the document on the Web API service. You can change the scenario and turn on other configuration settings by defining them in the processParams property and passing it to the configuration object.

Start the Processing

Now, you can start the document processing:

DocReader.shared.showScanner(self) { action, results, error in
    if action == .complete || action == .processTimeout {
        print(results ?? "nil")
    }

    if action == .error {
        print(error?.localizedDescription ?? "nil")
    }
}

See the other options of the document processing here.

Processing Configuration

The OnlineProcessingConfig object may contain the following config parameters:

Parameter Description
mode Determines the operation mode: RGLOnlineProcessingModeManual or RGLOnlineProcessingModeAuto.
processParams Сontains a set of processing parameters used during document recognition or data extraction.
serviceURL Specifies the web service endpoint or URL to which the SDK will send requests.
imageFormat Specifies the format of the input image or images, such as JPEG or PNG.
imageCompressionQuality Controls the level of compression applied to images during document recognition.
requestInterceptingDelegate A delegate that responds to request intercepting events. Use the delegate to modify URLRequest requests before they are sent to the web service.

You can learn more about OnlineProcessingConfig here.

Next Steps