DocumentScannerView

public struct DocumentScannerView : UIViewControllerRepresentable

A SwiftUI view that presents the VisionKit document scanner Note that VisionKit doesn’t currently provide a public API to customize the scan view’s appearance or behavior.

  • A type alias for a completion handler that takes a Result object containing either a ScanOutput or an Error as its argument

    Declaration

    Swift

    public typealias ScanCompletion = (Result<ScanOutput, Error>) -> Void
  • Callback to be executed when the scan is complete, with a Result object indicating success or failure

    Declaration

    Swift

    public var onCompletion: ScanCompletion
  • Desired output format for the scanned document

    Declaration

    Swift

    public var outputFormat: ScanOutputFormat
  • Initialize the view with the completion callback and output format

    Declaration

    Swift

    public init(onCompletion: @escaping ScanCompletion, outputFormat: ScanOutputFormat)
  • Create a VNDocumentCameraViewController and set its delegate

    Declaration

    Swift

    public func makeUIViewController(context: Context) -> VNDocumentCameraViewController
  • No need to update the UIViewController after it’s created

    Declaration

    Swift

    public func updateUIViewController(_ uiViewController: VNDocumentCameraViewController, context: Context)
  • Create a coordinator object to handle the delegate methods of the VNDocumentCameraViewController

    Declaration

    Swift

    public func makeCoordinator() -> Coordinator
  • Check if the device supports the document scanner

    Declaration

    Swift

    public static var isSupported: Bool { get }
  • Declaration

    Swift

    class Coordinator : NSObject, VNDocumentCameraViewControllerDelegate