Files
Pulse/Sources/PulseUI/Views/PDFRepresentedView.swift
T
2023-01-04 17:24:49 -05:00

41 lines
856 B
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// The MIT License (MIT)
//
// Copyright (c) 20202023 Alexander Grebenyuk (github.com/kean).
import SwiftUI
#if os(iOS)
import PDFKit
struct PDFKitRepresentedView: UIViewRepresentable {
let document: PDFDocument
func makeUIView(context: Context) -> PDFView {
let pdfView = PDFView()
pdfView.document = document
return pdfView
}
func updateUIView(_ view: PDFView, context: Context) {
// Do nothing
}
}
#elseif os(macOS)
import PDFKit
struct PDFKitRepresentedView: NSViewRepresentable {
let document: PDFDocument
func makeNSView(context: Context) -> PDFView {
let pdfView = PDFView()
pdfView.document = document
pdfView.autoScales = true
return pdfView
}
func updateNSView(_ view: PDFView, context: Context) {
// Do nothing
}
}
#endif