> For the complete documentation index, see [llms.txt](https://api2-ekycapis.innov8tif.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api2-ekycapis.innov8tif.com/okaycam-mobile-sdk/okaycam-plus-mobile-sdk/okaycam-plus-ios/development-guide-document-capture.md).

# Development Guide (Document Capture)

### Document Capture

1. Instantiate the configuration object. You must pass a reference to your navigation controller.

```swift
let config = OkayCamConfig(navigationController: nav)
```

The configuration object is initialized with default values.

2. Start the process by calling `start` on `OkayCamDoc` class. You can handle the result in the completion handler.

```swift
OkayCamDoc.start(
    okayCamConfig: config,
    license: yourLicense,
    { filePaths, error in
        // handle
    }
)
```

You will only either receieve `filePaths` or an `error`. One will be valid and the other will be `nil`.

### **Configuration**

Modifying the configuration object:

```swift
        let config = OkayCamConfig(navigationController: nav)
        config.topLabel.text = "top label text"
        config.topLabel.color = .green
        config.topLabel.size = 14
        config.bottomLabel.text = "bottom label text"
        config.bottomLabel.color = .systemPink
        config.bottomLabel.size = 20
        config.frame.color = .blue
        config.frame.size = CGSize(width: 230, height: 100)
        config.frame.content = URL(fileURLWithPath: Bundle.main.path(forResource: "image", ofType: "svg")!)
        config.showOverlay = false
        config.timer.backgroundColor = .magenta
        config.timer.textColor = .systemTeal
        config.captureBtnColor = .white
        config.torchBtnEnabled = false
        config.confirmBtnConfig.backgroundColor = .blue
        config.confirmBtnConfig.contentColor = .black
        config.retakeBtnConfig.backgroundColor = .orange
        config.retakeBtnConfig.contentColor = .black
        config.captureConfigPair = CaptureConfigPair(
            firstPhoto: OkayCamCaptureConfig(
                timeOut: 2,
                onFlash: false, 
                onImageQuality: false, // Required for SDK >= 2.0.0
                outputPath: myCustomFilePath
            ),
            secondPhoto: OkayCamCaptureConfig(
                timeOut: 1,
                onFlash: false, 
                onImageQuality: false, // Required for SDK >= 2.0.0
                outputPath: myCustomFilePath
            )
        )
        config.crop = true
        config.width = 250
        config.imageQuality = 1.0
```

Properties on `OkayCamConfig`:

| Property                                                                 | Default                                                                                                                                        | Type                 |
| ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- |
| topLabel                                                                 | `OkayCamLabelConfig(text: "Tap to focus", color: UIColor.white, size: CGFloat(24))`                                                            | `OkayCamLabelConfig` |
| bottomLabel                                                              | `OkayCamLabelConfig(text: "Please align ID card within frame", color: UIColor.white, size: CGFloat(24))`                                       | `OkayCamLabelConfig` |
| frame                                                                    | `OkayCamFrameConfig(size: nil, color: .white, content: nil)`                                                                                   | `OkayCamFrameConfig` |
| showOverlay                                                              | `true`                                                                                                                                         | `Bool`               |
| timer                                                                    | `OkayCamTimerConfig(backgroundColor: UIColor.black, textColor: UIColor.white)`                                                                 | `OkayCamTimerConfig` |
| captureBtnColor                                                          | `UIColor(red: 0.92, green: 0.08, blue: 0.30, alpha: 1.0)`                                                                                      | `UIColor`            |
| torchBtnEnabled                                                          | `false`                                                                                                                                        | `Bool`               |
| confirmBtnConfig                                                         | `OkayCamBtnConfig(backgroundColor: UIColor(red: 0.92, green: 0.08, blue: 0.30, alpha: 1.0), contentColor: UIColor.white)`                      | `OkayCamBtnConfig`   |
| retakeBtnConfig                                                          | `OkayCamBtnConfig(backgroundColor: UIColor(red: 0.92, green: 0.08, blue: 0.30, alpha: 1.0), contentColor: UIColor.white)`                      | `OkayCamBtnConfig`   |
| **SDK version 1.1.13 <=** **or SDK version 1.1.15 >=** captureConfigPair | `CaptureConfigPair(firstPhoto: OkayCamCaptureConfig(timeOut: 0, onFlash: false, outputPath: nil), secondPhoto: nil)`                           | `CaptureConfigPair`  |
| crop                                                                     | `false`                                                                                                                                        | `Bool`               |
| width                                                                    | `nil`                                                                                                                                          | `Int?`               |
| imageQuality                                                             | `1.0 (range 0 - 1.0)`                                                                                                                          | `CGFloat`            |
| frameSize                                                                | `nil`                                                                                                                                          |                      |
| autoCapture                                                              | <p></p><p><code>False</code> will disable autoCapture for documents.</p><p></p><p><code>True</code> will enable autocapture for documents.</p> | `Bool`               |
