-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathDocumentLocalizationUI2ViewController.swift
More file actions
86 lines (66 loc) · 3.25 KB
/
Copy pathDocumentLocalizationUI2ViewController.swift
File metadata and controls
86 lines (66 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
// DocumentLocalizationUI2ViewController.swift
// ScanbotSDK Examples
//
// Created by Rana Sohaib on 04.07.24.
//
import Foundation
import ScanbotSDK
class DocumentLocalizationUI2ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Start scanning here. Usually this is an action triggered by some button or menu.
Task {
await self.startScanning()
}
}
func startScanning() async {
// Create the default configuration object.
let configuration = SBSDKUI2DocumentScanningFlow()
// Retrieve the instance of the localization from the configuration object.
let localization = configuration.localization
// Configure the strings.
localization.cameraTopBarTitle = NSLocalizedString("document.camera.title", comment: "")
localization.reviewScreenSubmitButtonTitle = NSLocalizedString("review.submit.title", comment: "")
localization.cameraUserGuidanceNoDocumentFound = NSLocalizedString("camera.userGuidance.noDocumentFound", comment: "")
localization.cameraUserGuidanceTooDark = NSLocalizedString("camera.userGuidance.tooDark", comment: "")
// Present the view controller modally.
do {
let result = try await SBSDKUI2DocumentScannerController.present(on: self, configuration: configuration)
// Handle the result.
print(result.uuid)
print(result.pageCount)
print(result.documentImageSizeLimit)
print(result.pdfURI)
print(result.tiffURI)
print(result.creationDate)
// Check out other available properties in `SBSDKScannedDocument`.
result.pages.forEach { scannedPage in
print(scannedPage.uuid)
print(scannedPage.documentDetectionStatus)
print(scannedPage.polygon)
print(scannedPage.source)
let originalImage = scannedPage.originalImage
let originalImageURI = scannedPage.originalImageURI
let documentImage = scannedPage.documentImage
let documentImageURI = scannedPage.documentImageURI
let documentImagePreview = scannedPage.documentImagePreview
let documentImagePreviewURI = scannedPage.documentImagePreviewURI
if let documentQuality = scannedPage.documentQualityAssessment {
switch documentQuality {
case .acceptable: print("acceptable")
case .unacceptable: print("unacceptable")
case .uncertain: print("uncertain")
default: print("unknown")
}
}
// Check out other available properties in `SBSDKScannedPage`
}
} catch SBSDKError.operationCanceled {
print("The operation was cancelled before completion or by the user")
} catch {
// Any other error
print("Error scanning document: \(error.localizedDescription)")
}
}
}