laravel-pdfmerger icon indicating copy to clipboard operation
laravel-pdfmerger copied to clipboard

fixes no response being send on download

Open KreutzerCode opened this issue 2 years ago • 2 comments

After updating to version 1.3.1, no file download response was triggered when calling the download function, which may result in empty pdf files #31.

This is due to the new use of the "Illuminate\Http\Response" class inside of the download method.

        $output = $this->output();
        return new Response($output, 200, [
            'Content-Type' => 'application/pdf',
            'Content-Disposition' =>  'attachment; filename="' . $this->fileName . '"',
            'Content-Length' => strlen($output),
        ]);

The reason for the problem is that the response is generated and returned but not sent. To do this, we have to call the send method of the response class.

        $output = $this->output();
        $response = new Response($output, 200, [
            'Content-Type' => 'application/pdf',
            'Content-Disposition' =>  'attachment; filename="' . $this->fileName . '"',
            'Content-Length' => strlen($output),
        ]);
        return $response->send();

This solves the problem! (tested on laravel 9)

KreutzerCode avatar Oct 31 '22 20:10 KreutzerCode

Hi @Webklex , can we merge this?

wblondel avatar Jan 09 '23 04:01 wblondel

I got the problem this commit fixes ! Empty blank page when I tried to use the download() method. Thanks a lot for this fix, hope it gets merged soon

ankheur avatar Mar 24 '23 10:03 ankheur

Hi @KreutzerCode , many thanks for your time and effort to improve this library :)

Best regards & happy coding,

Webklex avatar Jul 02 '24 10:07 Webklex