// Auteur : Simon-Pierre Boucher — contact@spboucher.ai // Visionneuse des rapports PDF (pdfkit côté serveur, 100 % vectoriels) + partage. import SwiftUI import PDFKit struct PDFViewerView: View { let url: URL @Environment(\.dismiss) private var dismiss var body: some View { NavigationStack { PDFKitView(url: url) .ignoresSafeArea(edges: .bottom) .toolbar { ToolbarItem(placement: .principal) { Wordmark(size: 17) } ToolbarItem(placement: .topBarLeading) { Button("Fermer") { dismiss() } .font(.vpDisplayMedium(14)) .foregroundStyle(Color.vpInk) } ToolbarItem(placement: .topBarTrailing) { ShareLink(item: url) { Image(systemName: "square.and.arrow.up") .foregroundStyle(Color.vpInk) } } } .toolbarBackground(Color.vpPaper, for: .navigationBar) .toolbarBackground(.visible, for: .navigationBar) } } } private struct PDFKitView: UIViewRepresentable { let url: URL func makeUIView(context: Context) -> PDFView { let view = PDFView() view.autoScales = true view.backgroundColor = UIColor(Color.vpPaper) view.document = PDFDocument(url: url) return view } func updateUIView(_ view: PDFView, context: Context) { if view.document?.documentURL != url { view.document = PDFDocument(url: url) } } }