Download pdf file in browser Chrome com mPdf - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Download pdf file in browser Chrome com mPdf (/showthread.php?tid=75369) |
Download pdf file in browser Chrome com mPdf - PHS - 01-30-2020 Hello friends! I implemented the mPdf librarie in my project, including with the help of the staff here at the forum. The problem is that I am not able to download the pdf file through the Chrome browser. I generate the pdf with the library but when I click download the file in Chrome the file is not downloaded and a message is displayed that there is a problem with the server. In other browsers, Firefox and Edge the file is downloaded normally! Android also doesn't download. I took a look at the CodeIgniter documentation and tried several ways to force the download of the pdf file, but without success! In the controller, I'm calling by doing this: . PHP Code: .. Do I need to do anything else to be able to download the file through the browser Chrome? The version of mPdf is 8.0. I thank you in advance for any and all help. RE: Download pdf file in browser Chrome com mPdf - jreklund - 01-30-2020 Have you tried this? PHP Code: $pdf = $mpdf->Output('my-file.pdf', 'D')->setContentType('application/pdf'); And you should not use the return $pdf; part. As it should output to your browser, so just deleting that may help as well. RE: Download pdf file in browser Chrome com mPdf - PHS - 01-30-2020 (01-30-2020, 12:55 PM)jreklund Wrote: Have you tried this? Hello jreklund, thanks for the help! I had already tried it that way, but it returns ERR_INVALID_RESPONSE PHP Code: return $mpdf->Output('my-file.pdf', 'D'); |