Document Scanning – GBG IDscan Documentation

Document Scanning

If you would like to scan a document image with its metadata you should use IDSDocumentScannerController. To do so:

  • Initialise scanner controller and present it

Swift

let scannerController = IDSDocumentScannerController(scannerConfig: config)
scannerController.modalPresentationStyle = .fullScreen
scannerController.delegate = self
present(scannerController, animated: true, completion: nil) 
  • Implement IDSDocumentScannerControllerDelegate delegate protocol to receive events. Once document is scanned, you can extract document image in 2 ways: it depends whether it was captured automatically or with a help of manual capture button on the screen.

Swift

func documentScannerController(_ scanner: IDSDocumentScannerController, didFinishScanningWithInfo info: [AnyHashable : Any]) {
// First we check whether document was autocaptured if not - it was manually capture and we only have an image
    guard let metadata = info[IDSDocumentScannerInfoMetadataObject] as? IDESDocument else {
        self.extractedImgView.image = info[IDSDocumentScannerInfoImage] as? UIImage
        dismiss(animated: true, completion: nil)
        return
    }       
 
    // Extract image from metadata object
    self.extractedImgView.image = metadata.documentImage
    dismiss(animated: true)
} 

IDSDocumentScannerController is also capable to scan selfie images and utility documents. You can specify exact scanner type by providing a config to a constructor:

Swift

let config = IDSDocumentScannerConfig.builder().withScannerType(scannerType) 

Important note: The file size could be maximum 10mb, if it is over 10mb then error will be returned in the response. 

Was this page helpful?