-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
422 changed files
with
565 additions
and
476 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
Sources/IRLPDFScanContent/IRLPDFScanContent.docc/ClassicalDelegate.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
|
||
} | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
Sources/IRLPDFScanContent/IRLPDFScanContent.docc/SwiftUI.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} | ||
``` | ||
|
Oops, something went wrong.