Project

General

Profile

Actions

Feature #22483

open

Show PDF attachments and repo entries instead of downloading them

Added by Gregor Schmidt over 8 years ago. Updated over 2 years ago.

Status:
Needs feedback
Priority:
Normal
Category:
Attachments
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:

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

pdf-preview.png (54.7 KB) pdf-preview.png Gregor Schmidt, 2016-04-13 14:51
0001-Don-t-force-download-of-PDFs-but-show-in-browser-pre.patch (3.06 KB) 0001-Don-t-force-download-of-PDFs-but-show-in-browser-pre.patch Gregor Schmidt, 2016-05-09 11:08
0002-Show-pdf-preview-for-repository-files-and-attachment.patch (33.7 KB) 0002-Show-pdf-preview-for-repository-files-and-attachment.patch Gregor Schmidt, 2016-05-09 11:08
safari-error.png (61.5 KB) safari-error.png Go MAEDA, 2016-05-09 11:28
060719210727_example.pdf (18.5 KB) 060719210727_example.pdf text fixture (copy this file to /test/fixtures/files/2006/07 directory) Go MAEDA, 2016-05-09 18:00
060719210727_example.pdf (22.9 KB) 060719210727_example.pdf Gregor Schmidt, 2016-05-09 18:52

Related issues

Related to Redmine - Patch #27336: Render previews for audio and video filesClosedGo MAEDA

Actions
Has duplicate Redmine - Feature #22098: Open attached pdf files in the browserClosed

Actions
Has duplicate Redmine - Feature #36504: PDF preview in attachment PageClosed

Actions
Blocked by Redmine - Feature #22482: Respond with "No preview available" instead of sending the file when no preview is availableClosedJean-Philippe Lang

Actions
Actions

Also available in: Atom PDF