PDF preview or open in a new tab

Hello,

I would like PDFs not to be downloaded automatically, but instead to be previewed or opened in a new tab.

Does anyone have a solution for this?

1 Like

I think it can be influenced by the browser configuration. Zammad is not showing directly inline, because of security reasons, it will always be downloaded.

Also a duplicate of Improve article attachment preview for new file extensions Word, Excel and PDF

I think I understand the ask here, and I would agree it would be helpful: You can’t force the browser to use its built-in preview functionality, but you can encourage it by setting the Content-Disposition header to ā€œinlineā€ when serving the request for the file. For example: ā€˜Content-Disposition: inline; filename=ā€œsome_file.pdfā€ā€™, would cause Chrome-based and Firefox browsers to open the PDF in-browser, rather than downloading the file. I imagine images would work the same as well.

Iā€˜d suggest not to vote the denied duplicate and vote the favored one instead.

Apart from that, I believe that a software shouldnā€˜t decide how a browser should open a file for the user. Thatā€˜s a browser configuration, no?

I’ve voted over there, thanks for pointing that out.

Here’s the MDN documentation regarding the Content-Disposition header: Content-Disposition header - HTTP | MDN

I’d argue that it doesn’t force the browser to do anything, merely suggests the site’s intent with the content. Obviously, like everything with browsers, they all handle it a touch differently :rofl: .

1 Like