title: What will my PDF location be in local app files? - SwiftUI
body: <p>I have sourced a function that converts a view to a PDF from  another stack overflow post - <a href="https://stackoverflow.com/a/60753437/12969913">https://stackoverflow.com/a/60753437/12969913</a>. With this I am using another view to try and display the PDF inside a new view for the user to inevitably share and view as they wish.</p>
  <p>How do I get my PDF to display, I can't figure out how the URL works and what I have to put into the new view.</p>
  <p>The URL is created in the <code>exportToPDF()</code> function:</p>
  <pre><code>let documentDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
  let outputFileURL = documentDirectory.appendingPathComponent(&quot;SwiftUI.pdf&quot;)
  </code></pre>
  <p>I have then sourced some code to display the PDF from another stack overflow post and have implemented that - <a href="https://stackoverflow.com/a/61480852/12969913">https://stackoverflow.com/a/61480852/12969913</a>, but in order for this to work I have to put in my file URL, how do I do that, and what will the file URL be?</p>
  <p>My <code>PDFKitView()</code> Code - to display the new .pdf:</p>
  <pre><code>struct PDFKitView: View {
      var url: URL
      var body: some View {
          PDFKitRepresentedView(url)
      }
  }
  
  struct PDFKitRepresentedView: UIViewRepresentable {
      let url: URL
      init(_ url: URL) {
          self.url = url
      }
  
      func makeUIView(context: UIViewRepresentableContext&lt;PDFKitRepresentedView&gt;) -&gt; PDFKitRepresentedView.UIViewType {
          let pdfView = PDFView()
          pdfView.document = PDFDocument(url: self.url)
          pdfView.autoScales = true
          return pdfView
      }
  
      func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext&lt;PDFKitRepresentedView&gt;) {
          // Update the view.
      }
  }
  </code></pre>
  <p>I then go to display this using:</p>
  <pre><code>HStack{
      PDFKitView(url: ????????)
      Text(&quot;Hello World&quot;)
  }
  </code></pre>