title: Is There Any Way to Download a File (PDF) in the Controller After Inertia.js Post?
body: <p>I am using Laravel 8 with Jetstream Vuejs and Inertiajs and I am trying to download a PDF that's generating in my controller.</p>
  <p>I post my form's data:</p>
  <pre><code>previewPDF() {
        this.$inertia.post(&quot;/tracker/preview-pdf&quot;, this.form);
      },
  </code></pre>
  <p>Then in my controller I select the required data and generate the pdf for download:</p>
  <pre><code>function previewPDF(Request $request) {
         
         $pdfData = $this-&gt;getPDFData($request);
         $domainData = $this-&gt;getDomainData($request);
         $hourSumData = $this-&gt;getHourSumData($request);
         $userData = Auth::user();
         
         $pdf = PDF::loadView('trackerPDF', ['pdfData' =&gt; $pdfData, 'domainData' =&gt; $domainData, 'hourSumData' =&gt; $hourSumData, 'userData' =&gt; $userData]);
  
         return $pdf-&gt;download(&quot;pdfname.pdf&quot;);
     }
  </code></pre>
  <p>Due to the fact I posted the data with Inertia, my response is shown in a modal like so:</p>
  <p><a href="https://i.stack.imgur.com/Ki6ho.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ki6ho.png" alt="enter image description here" /></a></p>
  <p>The general thought on this seems to be to just not use Inertia for file downloads: <a href="https://stackoverflow.com/questions/65558569/laravel-inertia-js-file-download">Laravel &amp; inertia.js file download</a></p>
  <p>Is there any way to do this while still using Inertia? If not, is there proper way to handle this posting all of my form's data and not just an <code>&lt;a&gt;</code> link?</p>