Quick start Pixelnetica™ Document Scanning SDK for Apple iOS
This guide gets you from an empty project to a working document scanner using the ready-to-use camera screen. It takes about five minutes.
Before you begin
- Add the package. Add
DocScanningSDK-UIto your app — see Installation & SwiftPM integration. (The UI product includes the core engine, so you only need this one.) - Have a license key. Without an active license the SDK still runs, but results are watermarked. See Licensing, trial & evaluation to get a trial key.
- Allow camera access. Add an
NSCameraUsageDescriptionstring to your app’sInfo.plist— iOS requires it before the camera can start, and the scanner will fail without it.
1. Initialize the license at launch
Apply your license once, as early as possible — for example when the app starts. Passing nil runs the SDK in evaluation mode.
import DocScanningSDK
let status = PxLicense.initialize(withKey: myLicenseKey)
if status != PxLicenseStatus_Active {
// Evaluation mode: results will be watermarked.
}
2. Present the camera scanner
PxUiCameraScreenView is a SwiftUI view that runs the full capture experience — live edge detection, optional auto-shot, and a torch control — and calls you back with the result.
import SwiftUI
import DocScanningSDK_UI
struct ScanButton: View {
@State private var showCamera = false
var body: some View {
Button("Scan") { showCamera = true }
.fullScreenCover(isPresented: $showCamera) {
PxUiCameraScreenView(configuration: PxUiCameraScreenConfiguration()) { result in
showCamera = false
switch result {
case .success(let image, let cutout):
// `image` is the captured page; `cutout` is the detected
// document quad. Hand them to the crop editor or process
// them with the core engine.
break
case .cancelled:
break
case .failure(let error):
print((error as NSError).localizedDescription)
@unknown default:
break
}
}
.ignoresSafeArea()
}
}
}
That is a complete scanner. The screen returns a captured image and the detected document corners (cutout).
Where to go next
- Let the user fine-tune the crop: Edge detection & cropping.
- Recognise text and export a searchable PDF: OCR & text recognition and Export.
- Build a custom camera UI instead of the ready-to-use screen: Camera capture & live detection.
Tips
- Test camera capture on a real device — the Simulator has no camera, though you can still import an existing image.
- If the scanner closes immediately, check that
NSCameraUsageDescriptionis present inInfo.plist.