Failed to load PDF using Response Class
I am using Laravel 5.2, with Dompdf "barryvdh/laravel-dompdf": "^0.7.0". At first step, I am creating a PDF file with HTML input and saving it in storage path, which works fine. Later I have a link which helps rendering this saved pdf file in browser using Response class. The code snippet for that is shown below-
$filename = 'file.pdf';
$path = storage_path($filename);
return \Response::make(file_get_contents($path), 200, [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="'.$filename.'"'
]);
This works fine on my local machine, but throws error on pre-production and production server with alert message "Failed to load PDF".
Please need your help in understanding what's going wrong. Or else, is there any workaround I can do to load pdf file in browser?
Your help is much appreciated.
Please or to participate in this conversation.