Skip to content

Latest commit

 

History

History
200 lines (145 loc) · 7.22 KB

README.md

File metadata and controls

200 lines (145 loc) · 7.22 KB

IRLPDFScanContent

Super easy SwiftUI & UKKit pakcage to scan: Images or PDF. It is also a replacement for IRLScannerViewController

🍎 Documentation Quality Gate Status Version Platform Carthage compatible licence MIT

Overview

A convenient class usable from UIKit view controller or SwiftUI to scan document & get UIImage or PDFDocument as result

MINIMUM iOS REQUIREMENT: 13.0

Migration from IRLScannerViewController is feasible. Please check the tutorial available in the documentation.

You project should still work with depreciation warnings

Follow the tutorial to see how to beneficiate from the new system & remove the depreciation warnings.

One quick note, the new system support multiple scan. In this tutorial we cover how to get 1 scan. It is very straigth forward to get eveything else, check the doc.

Application plist requirement

As of iOS 10, you must povide a reason for using the camera in you Info.plist: Please add the following to your plist: NSCameraUsageDescription : We need the camera to scan

Install

Swift Package

Integrate the library via Swift Package (With Documentation)

In Xcode

Add the Package to your project, min version 5.5, See Apple Documentation for more details.

Manually

Create a Package.swift in a folder, then Drop the file on Xcode

// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
    name: "SPMDemo",
    products: [
        .library(
            name: "SPMDemo",
            targets: ["SPMDemo"]),
    ],
    dependencies: [
       .package(url: "git@github.com:charlymr/IRLPDFScanContent.git", from: "1.1.0"),
    ],
    targets: [
        .target( name: "SPMDemo",
            dependencies: [
                .product(name: "IRLPDFScanContent", package: "IRLPDFScanContent"),
        ])
    ]
)

CocoaPods

Integrate the library via CocoaPods

Install CocoaPods

if not already available:

$ [sudo] gem install cocoapods
$ pod setup

Update your Podfile

Change to the directory of your Xcode project, and Create and Edit your Podfile and add IRLPDFScanContent:

$ cd /path/to/MyProject
$ touch Podfile
## edit Podfile:

platform :ios, '13.0'

target "YOUR APP" do
    pod 'IRLPDFScanContent'
    use_frameworks!
end

Prepare project

run pod update or pod install to generate the Workspace

$ pod update

Carthage

Integrate the library via Carthage. For more details on Cartage and how to use it, check the Carthage Github documentation

Install Carthage

Install Carthage if not already available

Update your CartFile

Change to the directory of your Xcode project, and Create and Edit your CartFile and add IRLPDFScanContent:

$ cd /path/to/MyProject
$ touch CartFile
## edit CartFile:

github "charlymr/IRLPDFScanContent" ~> 1.1.0

Prepare

$ carthage update --use-xcframeworks 

Drop the Carthage/Build/iOS .xcframework in your project.

IRLPDFScanContent is a convenient way to use PDFKit in SwiftUI allowing the user to scan multiple pages and create a PDF for you. This tutorials will guides you through adding this functionality to a SwiftUI view or a UIVIewController. You will learn to build the view and hanlde the user input.

Chech the documentation (Essentials / Getting Started) here: Documentation for more details.

SwiftUI example

  • Initiate the object
  • present you view present(animated:)
  • Observe the result of latestScan
  • Use the convenient method swiftUIPDFView to update your view
import SwiftUI
import IRLPDFScanContent

struct ContentView: View {
    
    @ObservedObject var scanner: IRLPDFScanContent = IRLPDFScanContent()
        
    var body: some View {
        NavigationView {
            VStack() {
                 if let latestScan = scanner.latestScan {
                    latestScan.swiftUIPDFView
                    
                } else {
                    Text("Press the Scan button")
                }
            }
            .padding()
            .navigationBarItems(trailing: Button("Scan", action: {
                scanner.present(animated: true, completion: nil)
            }))
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Authors

Open Source

  • Feel free to fork and modify this code. Pull requests are more than welcome!

MIT License

Copyright (c) 2021 MARTIN-BRUILLOT Denis

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.