how to download html file or json file as pdf 

 

 

 

 

 

 

 

 

Serving files directly requires certain headers to be set. Fortunately, Laravel takes care of this for

you using the Response::download() shortcut. Let’s see this in action.

<?php

// app/routes.php

Route::get(‘file/download’, function()
{
$file = ‘path_to_my_file.pdf’;
return Response::download($file);
});
Now if you navigate to the /file/download URI the browser will intiate a download instead of
displaying a response.
The Response::download() method received a path to a file which will be
served when the response is returned.
There is given below an example that would explain a lot to you
<?php

// app/routes.php

Route::get(‘file/download’, function()
{
$file = ‘path_to_my_file.pdf’;
return Response::download($file, 200, array(‘first’, ‘second’,’third’,’fourth’));
});
I am using above 200 http status code that says everything is ok