CodeIgniter Forums
Showing pdf on browser - Printable Version

+- CodeIgniter Forums (
+-- Forum: CodeIgniter 4 (
+--- Forum: CodeIgniter 4 Support (
+--- 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.


even setting headers have not helped

return $this->response
            ->setHeader('Cache-Control','must-revalidate, post-check=0, pre-check=0')
            ->setHeader('Content-Disposition','inline; filename="'.$filename.'"')

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)

RE: Showing pdf on browser - aarefi - 04-16-2024

(04-16-2024, 02:07 AM)kenjis Wrote: This worked.

return $this->response->download(WRITEPATH . 'patterna.pdf', null)

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.