MBDocCapture 0.1.4

MBDocCapture 0.1.4

Maintained by El Mahdi BOUKHRIS.



  • By
  • El Mahdi BOUKHRIS

MBDocCapture

Version License Platform

MBDocCapture makes it easy to add document scanning functionalities to your iOS app but also image editing (Cropping and contrast enhacement).

Features

  • Doc scanning
  • Photo cropping and enhancement
  • Auto scan

Demo

Requirements

  • Swift 4.2
  • iOS 10.0+

Installation

Cocoapods

CocoaPods is a dependency manager for Cocoa projects.

To integrate MBDocCapture into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
pod 'MBDocCapture'
end

Then, run the following command:

$ pod install

Usage

Swift

  1. Make sure that your view controller conforms to the ImageScannerControllerDelegate protocol:
class YourViewController: UIViewController, ImageScannerControllerDelegate {
// YourViewController code here
}
  1. Implement the delegate functions inside your view controller:
/// Tells the delegate that the user scanned a document.
///
/// - Parameters:
///   - scanner: The scanner controller object managing the scanning interface.
///   - results: The results of the user scanning with the camera.
/// - Discussion: Your delegate's implementation of this method should dismiss the image scanner controller.
func imageScannerController(_ scanner: ImageScannerController, didFinishScanningWithResults results: ImageScannerResults) {
    scanner.dismiss()
}

/// Tells the delegate that the user scanned a document.
///
/// - Parameters:
///   - scanner: The scanner controller object managing the scanning interface.
///   - page1Results: The results of the user scanning page 1.
///   - page2Results: The results of the user scanning page 2.
/// - Discussion: Your delegate's implementation of this method should dismiss the image scanner controller.
func imageScannerController(_ scanner: ImageScannerController, didFinishScanningWithPage1Results page1Results: ImageScannerResults, andPage2Results page2Results: ImageScannerResults) {
    scanner.dismiss()
}

/// Tells the delegate that the user cancelled the scan operation.
///
/// - Parameters:
///   - scanner: The scanner controller object managing the scanning interface.
/// - Discussion: Your delegate's implementation of this method should dismiss the image scanner controller.
func imageScannerControllerDidCancel(_ scanner: ImageScannerController) {
    scanner.dismiss()
}

/// Tells the delegate that an error occured during the user's scanning experience.
///
/// - Parameters:
///   - scanner: The scanner controller object managing the scanning interface.
///   - error: The error that occured.
func imageScannerController(_ scanner: ImageScannerController, didFailWithError error: Error) {
    scanner.dismiss()
}
  1. Finally, create and present a ImageScannerController instance somewhere within your view controller:
    let scannerViewController = ImageScannerController(delegate: self)
    //scannerViewController.shouldScanTwoFaces = false // Use this to scan the front and the back of a document 
    present(scannerViewController, animated: true)

License

MBDocCapture is available under the MIT license. See the LICENSE file for more info.

Support

If this project helped you, buy me coffee ☕️

paypal