Feature #22483
openShow PDF attachments and repo entries instead of downloading them
0%
Description
Following up on #22058, I would like to propose, that also PDF files are shown directly instead of forcing downloads.
This applies to two use cases:
1. Following a download link¶
When following a download link, image are sent with content-disposition: inline
, while all other files are sent with attachment
. Since the some browsers is able to render PDF files directly (Firefox, Chrome, Safari, IE with Adobe Reader installed) and people are probably used to it, I think that extending this exception to PDF files is a reasonable change. If native PDF rendering within the browser is not supported, then a download will be initiated by the browser anyway.
2. Displaying a PDF file in repository browser¶
When accessing "View" within the file view in the repository browsers, Redmine currently forces a download of the PDF. Instead an iframe could be rendered which displays the PDF within the Redmine UI. Browser support for this use case is similar to No. 1.
The patch series is based on current trunk (r15332) plus the changes of #22482. If desired, I could isolate the changes further, to make them work without #22482.
0004-Don-t-force-download-of-PDFs-but-show-in-browser-pre.patch
¶
The change updates AttachmentsController
and RepositoryController
to send PDF files with content-disposition: inline
. (See first use case.)
0005-Show-pdf-preview-for-repository-files-and-attachment.patch
¶
The change adds attachments/pdf
and common/_pdf
views to render PDF files in an iframe/object construct. (See second use case.)
Since we cannot easily know the PDF’s dimensions, the frame size follows the following rules:
- it is as wide as possible (100%)
- in general it is as high as it is wide
- it is never higher than 80 % of the viewport (80vh), since we want to make sure, that there is always a bit of Redmine UI visible to avoid getting “trapped” within the frame
Using a nested object/iframe structure was taken from http://pdfobject.com/static.html
Files
Related issues