title: HTML2PDF - Download and display pdf file to page
body: <p>I am using HTML2PDF with Laravel 5.1. I have a problem with showing the pdf file on the page and downloading it to the server.</p>
  
  <p>When I use this code, it shows the pdf file without problems:</p>
  
  <pre><code>$pdf = $html2pdf-&gt;Output('', 'S'); 
  return response($pdf)
      -&gt;header('Content-Type', 'application/pdf')
      -&gt;header('Content-Length', strlen($pdf))
      -&gt;header('Content-Disposition', 'inline; filename="sample.pdf"');
  </code></pre>
  
  <p>However, the above code does not save the file to the server. So I tried this:</p>
  
  <pre><code>$filename = '\Report-' . $project-&gt;id . '.pdf';
  $output_path = base_path() . '\public\reports' . $filename;
  $pdf = $html2pdf-&gt;Output($output_path, 'F'); 
  return response($pdf)
      -&gt;header('Content-Type', 'application/pdf')
      -&gt;header('Content-Length', strlen($pdf))
      -&gt;header('Content-Disposition', 'inline; filename="'.$output_path.'"');
  </code></pre>
  
  <p>I've tried this in Chrome and in Firefox but it does not display the document, it just downloads the file to the server. What am I doing wrong?</p>