References
This page contains references for possible error codes, object structure, etc. In addition to this reference, the SDK has DocC support so you can inspect the objects using tools like Quick Help directly in Xcode.
Document scanner configuration parameters
This section describes the options within DocumentScannerConfig for customizing the document scanning experience.
autoCaptureToggleConfig: Controls auto-capture UI..show: Always show auto-capture toggle..hide: Hide auto-capture toggle..showDelayed(durationMs: Int): Show toggle after a delay (milliseconds).
documentSide: Which side to scan..front.back
documentType: Type of document..unknown.passport
The on-capture feedback is set separately, after initialization, using the
configureShutter mutating method (so the config must be declared as var).
See the Customization page for a full description of each effect.
configureShutter(screenFlash:hapticFeedback:sound:): Feedback played when a capture completes.screenFlash: Brief black flash mimicking a camera shutter. Defaults totrue.hapticFeedback: Haptic feedback on capture. Defaults tofalse.sound: Camera shutter sound on capture. Defaults tofalse.
Example:
import Document
let config = DocumentScannerConfig(
autoCaptureToggleConfig: .showDelayed(durationMs: 10_000),
documentSide: .front,
documentType: .passport
)
Result
This section describes the structure of the results returned by the document scanner SDK, including an example of how to handle the results.
DocumentScannerResult contains:
result:DocumentProcessingState.Result.success(Success)image:DocumentImageimage: Data (PNG)width,height,rotationisGood,isSharp,isGlareFree,isAdequateResolution
method:.manualCaptureor.smartCapture
.failure(Failure)message: Error messagecomponent:.smartCapture,.camera,.othercause: Optional error
metadata:DocumentProcessingMetadata(optional)blurryFrameCount,glareFrameCount,lowResFrameCount,documentBoundaryFrameCount,processedFrameCountcaptureDuration,lastFrameProcessingDurationhasDisabledAutoCapture
Example result handling:
if let result = sdk.documentScannerResult {
switch result.result {
case .success(let success):
// Access success.image and success.method
case .failure(let failure):
// Access failure.message and failure.component
}
if let metadata = result.metadata {
// Access frame counts and durations
}
}