Initialization

This page covers the description of the initialization process

Demo license can be obtained here: https://licensing.regulaforensics.com.

The initialization of Document Reader is performed fully offline. The initializeReader method process license as NSData, i.e. no matter when it's put to the project before the application is compiled or after. Here is an example of how to perform initialization with the license that is put to the resources of the project:

Initialization without databasePath

Swift
Objective-C
Swift
guard let dataPath = Bundle.main.path(forResource: "regula.license", ofType: nil) else { return }
guard let licenseData = try? Data(contentsOf: URL(fileURLWithPath: dataPath)) else { return }
DocReader.shared.initializeReader(license: licenseData) { (success, error) in
if success {
// DocumentReader successfully initialized
} else {
// DocumentReader not initialized
print(error)
}
}
Objective-C
NSString *dataPath = [[NSBundle mainBundle] pathForResource:@"regula.license" ofType:nil];
NSData *licenseData = [NSData dataWithContentsOfFile:dataPath];
[RGLDocReader.shared initializeReader:licenseData completion:^(BOOL success, NSError * _Nullable error ) {
if (success) {
// DocumentReader successfully initialized
} else {
// DocumentReader not initialized
NSLog(@"%@", error);
}
}];

Initialization with databasePath

Swift
Objective-C
Swift
guard let dataPath = Bundle.main.path(forResource: "regula.license", ofType: nil) else { return }
guard let licenseData = try? Data(contentsOf: URL(fileURLWithPath: dataPath)) else { return }
guard let dbDat = Bundle.main.path(forResource: "db.dat", ofType: nil) else { return }
DocReader.shared.initializeReader(license: licenseData, databasePath: dbDat) { (success, error) in
if success {
// DocumentReader successfully initialized
} else {
// DocumentReader not initialized
print(error)
}
}
Objective-C
NSString *dataPath = [[NSBundle mainBundle] pathForResource:@"regula.license" ofType:nil];
NSData *licenseData = [NSData dataWithContentsOfFile:dataPath];
NSString *dbDat = [[NSBundle mainBundle] pathForResource:@"db.dat" ofType:nil];
[RGLDocReader.shared initializeReader:licenseData databasePath:dbDat completion:^(BOOL success, NSError * _Nullable error) {
if (success) {
// DocumentReader successfully initialized
} else {
// DocumentReader not initialized
NSLog(@"%@", error);
}
}];