Skip to content

Commit

Permalink
Release 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
charlymr committed Nov 6, 2021
1 parent b4b61f0 commit e716d4b
Show file tree
Hide file tree
Showing 422 changed files with 565 additions and 476 deletions.
2 changes: 1 addition & 1 deletion Demo-Carthage/IRLPDFScanDemo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</array>
</dict>
</dict>
<key>NSCameraUsageDescription </key>
<key>NSCameraUsageDescription</key>
<string>We need the camera to scan</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion Demo-Cocoapods/IRLPDFScanDemo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</array>
</dict>
</dict>
<key>NSCameraUsageDescription </key>
<key>NSCameraUsageDescription</key>
<string>We need the camera to scan</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion IRLPDFScanContent.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Pod::Spec.new do |s|

s.name = "IRLPDFScanContent"
s.version = "1.0.0"
s.version = "1.0.1"
s.summary = "SwiftUI & UKKit - Images or PDF scanner."
s.description = "A convenient class usable from `UIKit` view controller or `SwiftUI` to scan document & get `UIImage` or `PDFDocument` as result"
s.license = { :type => 'MIT', :file => 'LICENSE' }
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# IRLPDFScanContent
`SwiftUI` & `UKKit` - Images or PDF scanner.

[![🍎 Documentation](https://raw.githubusercontent.com/charlymr/IRLPDFScanContent/main/documentationicon.png)](https://irlpdfscancontent.irlmobile.com/documentation/) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=charlymr_IRLPDFScanContent&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=charlymr_IRLPDFScanContent) [![Version](https://img.shields.io/cocoapods/v/IRLPDFScanContent.svg?style=flat)](http://cocoapods.org/pods/IRLPDFScanContent) [![Platform](https://img.shields.io/cocoapods/p/IRLPDFScanContent.svg?style=flat)](http://cocoapods.org/pods/IRLPDFScanContent)
[![🍎 Documentation](https://raw.githubusercontent.com/charlymr/IRLPDFScanContent/main/documentationicon.png)](https://irlpdfscancontent.irlmobile.com/documentation/) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=charlymr_IRLPDFScanContent&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=charlymr_IRLPDFScanContent) [![Version](https://img.shields.io/cocoapods/v/IRLPDFScanContent.svg?style=flat)](http://cocoapods.org/pods/IRLPDFScanContent) [![Platform](https://img.shields.io/cocoapods/p/IRLPDFScanContent.svg?style=flat)](http://cocoapods.org/pods/IRLPDFScanContent) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![licence MIT](https://shields.io/badge/license-MIT-%23373737)](https://github.com/charlymr/IRLPDFScanContent/blob/main/LICENSE)

## Overview

Expand All @@ -15,9 +16,9 @@ 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](https://developer.apple.com/documentation/bundleresources/information_property_list/nscamerausagedescription) : We need the camera to scan**

## Usage
## Install

### via Swift Package Manager
### via Swift Package (With Documentation)

Add the Package to your project, min version `5.5`, See [Apple Documentation](https://developer.apple.com/documentation/swift_packages/adding_package_dependencies_to_your_app).

Expand Down Expand Up @@ -58,15 +59,14 @@ Change to the directory of your Xcode project, and Create and Edit your Podfile
``` bash
$ cd /path/to/MyProject
$ touch Podfile
$ edit Podfile
## edit Podfile:

platform :ios, '13.0'

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

```

### via Carthage
Expand All @@ -78,7 +78,7 @@ Change to the directory of your Xcode project, and Create and Edit your Podfile
``` bash
$ cd /path/to/MyProject
$ touch CartFile
$ edit CartFile
## edit CartFile:

github "charlymr/IRLPDFScanContent" ~> 1.0.1
```
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Classical Delegate

``IRLPDFScanContent`` provide a ``IRLPDFScanContent/IRLPDFScanContent/delegate`` call for each action taken by the scanner. Check ``IRLPDFScanContentProtocol`` for more details

## Overview

This section is more for usage with a classical `UIViewController`

##### Perfrom a Scan

- Initiate the object with ``IRLPDFScanContent/IRLPDFScanContent/init(with:)`` (You may pass a delegate (``IRLPDFScanContent/IRLPDFScanContentProtocol``) or observe changes
- present you view ``IRLPDFScanContent/IRLPDFScanContent/present(animated:completion:)
- Wait for ``IRLPDFScanContent/IRLPDFScanContent/delegate`` to be call on the method: ``IRLPDFScanContent/IRLPDFScanContentProtocol/scanContent(caller:didScan:)``
- Generate a PDF using ``IRLPDFScanContent/IRLPDFScanContent/generatePDF(with:)`` and get the URL. (Or get images using ``IRLPDFScanContent/IRLPDFScanContent/scanImages``)
- Pass it a classical: [`PDFView`](https://developer.apple.com/documentation/pdfkit/pdfview)

``` swift
import UIKit
import IRLPDFScanContent

class ViewController: UIViewController {

let scanner = IRLPDFScanContent()

@IBOutlet weak var text: UILabel!

@IBOutlet weak var pdfView: PDFView!

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
view.bringSubviewToFront(text)
}

@IBAction func startScan(_ sender: Any) {
pdfView.document = nil
text.text = "Use the Scan Button"
scanner.delegate = self
scanner.present(animated: true, completion: nil)
}

}

extension ViewController: IRLPDFScanContentProtocol {

func scanContent(caller: IRLPDFScanContent, didScan scan: VNDocumentCameraScan) {
guard let url = caller.generatePDF() else {
return
}
view.sendSubviewToBack(text)
pdfView.document = PDFDocument(url: url)
pdfView.autoScales = true
}

func scanContent(caller: IRLPDFScanContent, didFail error: Error) {
view.bringSubviewToFront(text)
text.text = error.localizedDescription
}

}

```
40 changes: 10 additions & 30 deletions Sources/IRLPDFScanContent/IRLPDFScanContent.docc/Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,27 @@ A convenient class usable from `UIKit` view controller or `SwiftUI` to scan docu

- Check it out on [Github](https://github.com/charlymr/IRLPDFScanContent)

## Available

- iOS 13+

## Installation

#### Swift Package Manager, `5.5`+ if you want to build the documentation
- Add the Package to your project, min version `5.5`, See [Apple Documentation](https://developer.apple.com/documentation/swift_packages/adding_package_dependencies_to_your_app).
- Add this Package to your project: `[email protected]:charlymr/IRLPDFScanContent.git` from version: `1.0.0`
- In your `Project` / `Targets` / `<Name of your App>` / `General` / `Frameworks, Libraries, and Embededded Content` make sure you add ``IRLPDFScanContent`` Library

#### CocoaPods

Install CocoaPods if not already available:
#### To Make it availble globaly in your project

``` bash
$ [sudo] gem install cocoapods
$ pod setup
- In your `AppDelegate` or your Module, use `@_exported` for convenience
```swift
@_exported import IRLPDFScanContent
```

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

``` bash
$ cd /path/to/MyProject
$ touch Podfile
$ edit Podfile
## Available

platform :ios, '13.0'
- iOS 13+

target "YOUR APP" do
pod 'IRLPDFScanContent'
use_frameworks!
end
```
Check the documentation (Essentials / Getting Started) here: [Documentation](https://irlpdfscancontent.irlmobile.com/tutorials/tutorial-table-of-contents) for more details


## Topics

### Essentials

- <doc:/tutorials/Tutorial-Table-of-Contents>
- <doc:About>
- <doc:GettingStarted>
- <doc:/tutorials/Tutorial-Table-of-Contents>
- <doc:ClassicalDelegate>
- <doc:SwiftUI>

48 changes: 21 additions & 27 deletions Sources/IRLPDFScanContent/IRLPDFScanContent.docc/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ 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](https://developer.apple.com/documentation/bundleresources/information_property_list/nscamerausagedescription) : We need the camera to scan**

## Usage
## Install

### via Swift Package (With Documentation)

### Swift Package (With Documentation)
Add the Package to your project, min version `5.5`, See [Apple Documentation](https://developer.apple.com/documentation/swift_packages/adding_package_dependencies_to_your_app).

```swift
Expand All @@ -42,7 +43,7 @@ let package = Package(
)
```

### CocoaPods
### via CocoaPods

Install CocoaPods if not already available:

Expand All @@ -56,43 +57,36 @@ Change to the directory of your Xcode project, and Create and Edit your Podfile
``` bash
$ cd /path/to/MyProject
$ touch Podfile
$ edit Podfile
## edit Podfile:

platform :ios, '13.0'

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

## [Getting started](https://irlpdfscancontent.irlmobile.com)
### via Carthage

IRLPDFScanContent is a convenient way to use PDFKit in SwiftUI allowing the user to scan multiple pages and creating a PDF for you.
This tutorial guides you through building adding this functionality to a SwiftUI view. You will learn to build the view and hanlde the user input.
Install [Carthage](https://github.com/Carthage/Carthage#installing-carthage) if not already available

Check the documentation (Essentials / Getting Started) here: [Documentation](https://irlpdfscancontent.irlmobile.com/tutorials/tutorial-table-of-contents)
Change to the directory of your Xcode project, and Create and Edit your Podfile and add IRLPDFScanContent:

#### Make it availble globaly
``` bash
$ cd /path/to/MyProject
$ touch CartFile
## edit CartFile:

- In your `AppDelegate` or your Module, use `@_exported` for convenience
```swift
@_exported import IRLPDFScanContent
github "charlymr/IRLPDFScanContent" ~> 1.0.1
```

### Perfrom a Scan
Save and run:
``` bash
$ carthage update --use-xcframeworks
```
Drop the Carthage/Build/iOS .framework in your project.

- Initiate the object with [`init(with:)`](https://irlpdfscancontent.irlmobile.com) (You may pass a delegate (`IRLPDFScanContentProtocol`) or observe changes
- present you view [`present(animated:completion:)`](https://irlpdfscancontent.irlmobile.com) or [`await present(animated:)`](https://irlpdfscancontent.irlmobile.com) (iOS 15.0+)
- Observe the result of [`latestScan`](https://irlpdfscancontent.irlmobile.com) or wait for `delegate` if you used the delegate method
- Generate a PDF using [`generatePDF(with:)`](https://irlpdfscancontent.irlmobile.com) or get images using `scanImages`
For more details on Cartage and how to use it, check the [Carthage Github](https://github.com/Carthage/Carthage) documentation

``` swift
let scanner = IRLPDFScanContent(with: self)
scanner.present(animated: true, completion: nil)

// .... Later stage
guard let pdfURL = scanner.generatePDF(with: "myscan.pdf") else {
return
}
```
51 changes: 51 additions & 0 deletions Sources/IRLPDFScanContent/IRLPDFScanContent.docc/SwiftUI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# SwiftUI

``IRLPDFScanContent`` has a convenient way to use `PDFKit` in SwiftUI allowing the user to scan multiple pages and creating a PDF for you.

## Overview

Check the documentation (Essentials / Getting Started) here: [Documentation](https://irlpdfscancontent.irlmobile.com/tutorials/tutorial-table-of-contents)

### Perfrom a Scan

- Initiate the object with ``IRLPDFScanContent/IRLPDFScanContent/init(with:)``
- present you view `await` ``IRLPDFScanContent/IRLPDFScanContent/present(animated:)`` (iOS 15.0+)
- Observe the result of ``IRLPDFScanContent/IRLPDFScanContent/latestScan``
- Use the convenient method ``IRLPDFScanContent/IRLVNDocumentCameraScanAdditions/swiftUIPDFView`` to update your view

``` swift
import SwiftUI
import IRLPDFScanContent

struct ContentView: View {
@ObservedObject var scanner: IRLPDFScanContent = IRLPDFScanContent()
@State var pdfView: IRLPDFView? = nil
var body: some View {
NavigationView {
VStack() {
if let pdfView = pdfView {
pdfView
} else {
Text("Press the Scan button")
}
}
.padding()
.navigationBarItems(trailing: Button("Scan", action: {
Task {
await scanner.present(animated: true)
}
}))
.onChange(of: scanner.latestScan) { newValue in
pdfView = newValue?.swiftUIPDFView
}
}
}
}

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

Loading

0 comments on commit e716d4b

Please sign in to comment.