title: "The Response callback must not be null" when trying to send a PDF file download in Laravel 7
body: <p>In my Laravel 7 application, I have a route where a PDF is dynamically generated, and I want the browser to treat it as a file download.</p>
  <p>In writing this, I found a number of docs and questions about Laravel serving a file download using a file saved on the filesystem, but in my case, I don't want to store the pdf in the filesystem. I just want to dynamically generate it when the user hits the route, and then the browser downloads the pdf.</p>
  <p>I'm using the mpdf library and it appears that it is properly forming a pdf file. However, Laravel is throwing a <code>The Response callback must not be null</code> LogicException. In the browser, I see the data of the PDF displayed, followed by the exception stack trace.</p>
  <p>Here's the controller method:</p>
  <pre><code>public function pdf($id) {
      $manual = new \App\manual($id);
      $contents = view('admin.manual')-&gt;with($manual)-&gt;render();
      $mpdf = New \Mpdf\Mpdf();
      $mpdf-&gt;WriteHtml($contents);
      $pdf = $mpdf-&gt;output();
      return response()-&gt;streamDownload($pdf, 'manual.pdf');
  }
  </code></pre>
  <p>In this screenshot, you can see the data of the PDF file, which tells me its being generated and delivered: <a href="https://i.stack.imgur.com/ChClv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ChClv.png" alt="enter image description here" /></a></p>
  <p>However the exception follows after the EOF of the PDF object:
  <a href="https://i.stack.imgur.com/xXVzV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xXVzV.png" alt="enter image description here" /></a></p>
  <p>I found <a href="https://github.com/symfony/symfony/issues/15564" rel="nofollow noreferrer">this 5-year-old issue</a> from Symfony for the same exception message, but it seems to have been long resolved. I've found nothing else in relation to Laravel 7.</p>
  <p>How do I properly specify a pdf file download of data in Laravel 7?</p>