Skip to content

Initialization

How to perform the initialization of Document Reader SDK.

Overview

You can obtain a demo license here: https://licensing.regulaforensics.com

The initializeReaderWithConfig method initializes the Document Reader SDK. It accepts an instance of the RGLConfig class as a configuration object.

The RGLConfig allows you to set the license for the Document Reader SDK and other configuration properties. For more information, please see the documentation for RGLConfig.

The initialization of the Document Reader SDK is performed fully offline, although by default the SDK attempts to access the licensing server. You can change this behavior by setting the RGLConfig instance property licenseUpdateCheck to false.

Here is an example of how to perform initialization with the license stored in the application bundle:

guard let licensePath = Bundle.main.path(forResource: "regula.license", ofType: nil) else { return }
guard let licenseData = Data(contentsOf: URL(fileURLWithPath: licensePath)) else { return }
let config = DocReader.Config(license: licenseData)

DocReader.shared.initializeReader(config: config) { (success, error) in
    if success {
        // DocumentReader successfully initialized
    } else {
        // DocumentReader not initialized
        print(error)
    }
}
NSString *licensePath = [[NSBundle mainBundle] pathForResource:@"regula.license" ofType:nil];
NSData *licenseData = [NSData dataWithContentsOfFile:licensePath];
RGLConfig *config = [RGLConfig configWithLicenseData:licenseData];

[RGLDocReader.shared initializeReaderWithConfig:config completion:^(BOOL success, NSError *error) {
    if (success) {
        // DocumentReader successfully initialized
    } else {
        // DocumentReader not initialized
        NSLog(@"%@", error);
    }
}];

With Custom Database Path

Also, you can use a custom database path:

guard let licensePath = Bundle.main.path(forResource: "regula.license", ofType: nil) else { return }
guard let licenseData = Data(contentsOf: URL(fileURLWithPath: licensePath)) else { return }
let databasePath = Bundle.main.path(forResource: "db.dat", ofType: nil)
let config = DocReader.Config(license: licenseData, licenseUpdateCheck: true, databasePath: databasePath)

DocReader.shared.initializeReader(config: config) { (success, error) in
    if success {
        // DocumentReader successfully initialized
    } else {
        // DocumentReader not initialized
        print(error)
    }
}
NSString *licensePath = [[NSBundle mainBundle] pathForResource:@"regula.license" ofType:nil];
NSData *licenseData = [NSData dataWithContentsOfFile:licensePath];
NSString *databasePath = [[NSBundle mainBundle] pathForResource:@"db.dat" ofType:nil];
RGLConfig *config = [RGLConfig configWithLicenseData:licenseData licenseUpdateCheck:YES databasePath:databasePath];

[RGLDocReader.shared initializeReaderWithConfig:config completion:^(BOOL success, NSError *error) {
    if (success) {
        // DocumentReader successfully initialized
    } else {
        // DocumentReader not initialized
        NSLog(@"%@", error);
    }
}];
Back to top