![]() |
Showing pdf on browser - 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: Showing pdf on browser (/showthread.php?tid=90672) |
Showing pdf on browser - aarefi - 04-15-2024 I need a way to show a pdf file on browser in codeignter v4.4.0 or later. I have tried inline method in download response but it always downloads the pdf file. $this->response->download(.......)->inline(); even setting headers have not helped return $this->response ->setHeader('Pragma','public') ->setHeader('Expires','0') ->setHeader('Cache-Control','must-revalidate, post-check=0, pre-check=0') ->setHeader('Content-Disposition','inline; filename="'.$filename.'"') ->setContentType('application/pdf') ->setHeader('Content-Length',strlen($data)) ->download($filename,$data,true); Would you please help me? RE: Showing pdf on browser - InsiteFX - 04-15-2024 How to open a PDF files in web browser using PHP? RE: Showing pdf on browser - kenjis - 04-16-2024 This worked. return $this->response->download(WRITEPATH . 'patterna.pdf', null) ->setContentType('application/pdf') ->inline() ; RE: Showing pdf on browser - aarefi - 04-16-2024 (04-16-2024, 02:07 AM)kenjis Wrote: This worked. Thank you kenjis. It works great. Of course I should disable "Internet Download Manager program" so the pdf be shown on the browser. In v3.4.8 and older the pdf file was shown without disabling that program when I set the headers. |