1

This is what I have now:

$file = $generation->pdfStoragePath().'/'.$downloaded_filename;
$headers = [
    'Content-type' => 'application/pdf',
    'Content-Disposition' => 'inline; filename="' . $downloaded_filename . '"',
    'Content-Transfer-Encoding' => 'binary',
    'Accept-Ranges' => 'bytes', 
];

return Response::download($file, $downloaded_filename, $headers);

The problem is, every time I try to open the link to get the file, the file downloads instead of showing in the browser window. As you can see, I tried to set the headers following this blog: http://yogeshchaugule.com/blog/2013/how-display-pdf-browser-php but without success. Any ideas, where's the problem?

Rafael Korbas
  • 2,213
  • 3
  • 19
  • 30
  • Have you tried more than one browser, or confirmed that you can view *some* PDF file inline in the current browser? Perhaps the browser you are using does not know how to handle display of PDF documents. – Eric J. Jul 16 '15 at 21:30
  • i'm using chrome 43.0.2357.134. I think, I found the solution: http://stackoverflow.com/questions/25938294/laravel-display-a-pdf-file-in-storage-without-forcing-download . Now the file tries to show in browser but the browser "failed to load the pdf document" – Rafael Korbas Jul 16 '15 at 21:37
  • Did you try to just set the header content type and then do `readfile($file);` ? – DavidDomain Jul 16 '15 at 21:39
  • Looks like that answer should work. If it does, close your question as a duplicate of the other one. – Eric J. Jul 16 '15 at 21:40
  • yes, it worked. Thanks for your effort :) I forgot "file_get_contents(...)" in Response:make, that's why it failed to load. – Rafael Korbas Jul 16 '15 at 21:42

0 Answers0