Skip to content

Latest commit

 

History

History
127 lines (96 loc) · 3.97 KB

README.md

File metadata and controls

127 lines (96 loc) · 3.97 KB

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
  • Add photo via gallery

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