Document Scan
The Docutain Document Scanner SDK for iOS comes with integrated, ready to use UI components for the document scan process. Colors and icons can be changed to match your branding.
Start the document scanner
Initialize the Docutain iOS Scanner SDK as described here.
You need to specify the reason for requesting access to the camera as part of the NSCameraUsageDescription
in the Info.plist
. If you don't the app will crash.
To start the scan process you only have to implement our predefined ScanDelegate
, implement it's didFinishScan
method and call the static UI.scanDocument
method at the place you want to start the document scanner, e.g. in a button click handler.
import DocutainSdk
class ViewController: UIViewController, ScanDelegate {
//...
func didFinishScan(withResult result: Bool) {
if(result){
//user finished scan process, continue with your workflow
//generate PDF by using Document.writePDF()
//get detected Text by using DocumentDataReader.getText()
//get data by using DocumentDataReader.analyze()
} else{
//user canceled scan process
}
}
@objc private func scanButtonClicked(){
let scanConfig = DocumentScannerConfiguration()
UI.scanDocument(scanDelegate: self, scanConfig: scanConfig)
}
//...
}
An instance of DocumentScannerConfiguration
is required to launch the document scanner. It provides the possibility to change some behaviours to adopt it to your needs.
let scanConfig = DocumentScannerConfiguration()
scanConfig.allowCaptureModeSetting = true //defaults to false
scanConfig.pageEditConfig.allowPageRotation = true //defaults to true
scanConfig.pageEditConfig.allowPageFilter = true //defaults to true
scanConfig.autoCapture = true //defaults to true
scanConfig.defaultScanFilter = .illustration //defaults to ScanFilter.illustration
All parameters in DocumentScannerConfiguration
are optional.
Result handling
After the scan process is successfully finished, you can do a bunch of things with the scanned pages: