Display PDF files in the browser in laravel

author
0 minutes, 21 seconds Read

Use the stream() method to send a file to the browser without triggering a download.
If you want to return file content without initiating a download, you can use the stream() method. It will display the file in the browser.

// It returns a PDF as a binary string

$pdf = ThirdPartyApp::pdf ($id);

$headers = ['Content-Type' => 'application/pdf'];

return response()->stream (function () use ($pdf) {
   echo $pdf;
}, Response::HTTP_OK, $headers);
PHP
Share To:

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *