The Mobscanner SDK for IOS is designed to perform faster image scanning and produce quality PDFs with few clicks. The SDK provides out of the box accurate, fast, and reliable mobile document scanning SDK for Android and IOS. Use any smart device to quickly and accurately digitize the documents you need. Implement the Ready-To-Use UI (RTU UI) with only a few lines of code cuts down the development cost and time for the business. The SDK is written in Swift.
Operating System
• IOS 11.0 and higher
Hardware
• Rear-facing camera with autofocus
• Supported CPUs and Architectures : arm64,x86_64
The MobScanner SDK works completely offline. All data generated by the MobScanner SDK is only stored on the end user’s device and in absolutely no case ever transferred to a server / cloud service controlled by us. You as the customer will need to take care of uploading the scans / data to your backend, if desired.
Pick images from camera or gallery
Supports multiple image scanning
Auto edge detection
Alignment correction
Perspective Transformation
Intelligent Image Filter for enhancement
Offline mode
API support
We will explain the usage of the SDK in the following section.
The SDK can be downloaded and configured using pod. Open your project pod file and paste below line after 'use_frameworks!'
pod 'MobScannerSDK', :git => "https://github.com/mobspace/iMobScannerSDK.git"
Use Pod install
command to install the SDK.
Additionaly update info.plist
with below keys to include Camera and Photo Library permission, that required by the SDK
Privacy - Photo Library Usage Description
Privacy - Camera Usage Description
In order to use the SDK, the developer needs a Unique Account Id (UUID) and an API Key. The UUID defines a unique ID for a vendor/business, while API Key is specific to an App owned by the Vendor and it is unique to the "App Package Id". The same can be obtained by contacting us. However, for evaluation purpose there is an API key/UUID available in the sample project. Download the project and open in Xcode to run the App. Please note, the given demo key wouldn't work in any other App. Use pod install
to install the MobScanner SDK into the Sample App
Once you get the API key and UUID, use the below code to initialize the App.
MobScannerSDK.initialize(uuid: "32937f98-6e8e-451d-a932-fd64b9c7635e",apiKey: "0922c2075ed349eee0b54d610848aad1de285e36",initCallBack: self)
MobScannerSDK.initialize()
is an asyn call. The initialization status would be reported through SDKInitDelegate
. The Initialization would fail for invalid UUID or API Key.
Optionally, you can set theme to match the SDK UI with your App. Create your own implementaion class for SDKColors
protocol.
class MyThemeColors: SDKColors{
/// Used as the background color for nav bars
var navBackgroundColor: UIColor = {
if #available(iOS 13.0, *) {
return .systemBackground
} else {
return .white
}
}()
/// This is the primary action color used for tinting buttons like the Back, Done and other Button color
public var primaryColor: UIColor = {
if #available(iOS 13.0, *) {
return .link
} else {
return .orange
}
}()
/// The main color for text labels.
public let label: UIColor = {
if #available(iOS 13.0, *) {
return .label
} else {
return .black
}
}()
}
Apply the theme as
MobScannerSDK.setTheme(theme: MyThemeColors())
The SDK comes with RTU UI (Ready to use UI) feature. The design is optimal from App functionality point of view. The SDK has below built in ViewControllers-
- CameraViewController - For capturing images from camera
- CropViewController - For croping ROI (Region of Interest) from the document scanned including image rotation.
- ImageFilterViewController- For applying image filters for enhancment. This ViewController implicitly used by the CropViewController
- DeviceImagerPicker - ViewController to pick images from photo library.
To use these ViewControllers add the target ViewController to the Storyboard of your app and assign corresponding Storyboard ID. Also make sure to assign Module as 'MobScannerSDK'. Note, please make sure to add 'ImageFilterViewController' to storyboard and assign Storyboard ID as 'ImageFilterViewController'.
Before using Camera or Photo Gallery, make sure that your App has necessary permissions as described above.
func openCamera(){
let camera = self.storyboard?.instantiateViewController(withIdentifier: "CameraViewController") as! CameraViewController
// delegate to report captured images
camera.inputImagePickerDelegate = self
/// settings to show capture preview
camera.showCapture = true
/// settings to indicate if we need a single shot only from the camera.
camera.isSingleShot = false
self.navigationController?.pushViewController(camera, animated: true)
}
Implement the InputImagePickerDelegate
delegate for callback, once user finishes capturing/selecting images from camera or photo gallery.
ViewController to select multiple photos from photo library. Start it as-
func openGallery(){
let deviceImagePicker = DeviceImagerPicker()
// delegate to report selected images
deviceImagePicker.inputImagePickerDelegate = self
self.present(deviceImagePicker, animated: true, completion: nil)
}
Once images are picked by the user launch 'CropViewController' to edit them further.
func onInputImagePicked(images: [String]) {
let cropView = self.storyboard?.instantiateViewController(withIdentifier: "CropViewController") as! CropViewController
// assign images for editing
cropView.imgFiles = images
// cropView.outputFolder = "SampleOutputFolder" // Optional
// delegate to report once all images are edited by the user
cropView.documentReadyDelegate = self
self.navigationController?.pushViewController(cropView, animated: true);
}
Note, please make sure to add 'ImageFilterViewController' to storyboard and assign Storyboard ID as 'ImageFilterViewController'. CropViewController implicitly uses ImageFilterViewController to apply filter on cropped images. By default images would be stored in Document folder.
Implement DocumentReadyDelegate
delegate to receive edited images from CropViewController.
You can use inbuilt PDF generator to create PDF from images.
Img2Pdf.createPDF(jpegFiles: outputImgFiles, outputFileName: "test.pdf", callback: {(pdfUrl) -> () in
// preview generated PDF
let pdfView = PDFView(frame: self.view.bounds)
self.view.addSubview(pdfView)
// Fit content in PDFView.
pdfView.autoScales = true
// Load pdf file.
pdfView.document = PDFDocument(url: pdfUrl!!)
print(FileManager.default.fileExists(atPath: pdfUrl!!.path) )
})
For any issue of the SDK please write to us. Or you can create a github issue here