DocumentScannerView

main

Native document scanning in SwiftUI
edonv/DocumentScannerView

DocumentScannerView

DocumentScannerView is a SwiftUI wrapper of 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:

...

@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:

...

@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
            }
        }
}

...

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

  • None
Last updated: Wed Nov 20 2024 02:10:36 GMT-1000 (Hawaii-Aleutian Standard Time)