![]() |
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?
How to open a PDF files in web browser using PHP?
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
This worked.
return $this->response->download(WRITEPATH . 'patterna.pdf', null) ->setContentType('application/pdf') ->inline() ; (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. |
Welcome Guest, Not a member yet? Register Sign In |