Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/edonv/documentscannerview
Native document scanning in SwiftUI
https://github.com/edonv/documentscannerview
document ios scanner swift swiftui vndocumentcameraviewcontroller
Last synced: 2 months ago
JSON representation
Native document scanning in SwiftUI
- Host: GitHub
- URL: https://github.com/edonv/documentscannerview
- Owner: edonv
- License: mit
- Created: 2023-09-23T19:03:47.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-09T19:54:50.000Z (8 months ago)
- Last Synced: 2024-10-14T12:49:11.239Z (3 months ago)
- Topics: document, ios, scanner, swift, swiftui, vndocumentcameraviewcontroller
- Language: Swift
- Homepage:
- Size: 16.6 KB
- Stars: 12
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DocumentScannerView
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fedonv%2FDocumentScannerView%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/edonv/DocumentScannerView)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fedonv%2FDocumentScannerView%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/edonv/DocumentScannerView)`DocumentScannerView` is a SwiftUI wrapper of [`VNDocumentCameraViewController`](https://developer.apple.com/documentation/visionkit/vndocumentcameraviewcontroller). Use it for scanning documents using the native document scanner.
## Example
To use `DocumentScannerView`, you can either:
Present it inside the ViewBuilder of a `.fullScreenCover(isPresented:)` ViewModifier:
```swift
...@ViewBuilder
var body: some View {
// {Other View Content}
.fullScreenCover(isPresented: $showScanner) {
DocumentScannerView { scanResult in
switch scanResult {
case .success(let pages): // pages can either be [UIImage] or a PDFDocument
// Do something with the scan
case .failure(let error):
// Deal with error
}
}
}
}...
```OR
You can use the provided ViewModifier:
```swift
...@ViewBuilder
var body: some View {
// {Other View Content}
.documentScanner(isPresented: $showScanner) { scanResult in
switch scanResult {
case .success(let pages): // pages can either be [UIImage] or a PDFDocument
// Do something with the scan
case .failure(let error):
// Deal with error
}
}
}...
```