https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292016-04-13T12:51:51ZRedmineRedmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=703162016-04-13T12:51:51ZGregor Schmidtschmidt@nach-vorne.eu
<ul><li><strong>File</strong> <a href="/attachments/15749">pdf-preview.png</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/15749/pdf-preview.png">pdf-preview.png</a> added</li></ul><p><img src="https://www.redmine.org/attachments/download/15749/pdf-preview.png" alt="" /></p> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=704392016-04-18T12:11:54ZGo MAEDA
<ul><li><strong>Blocked by</strong> <i><a class="issue tracker-2 status-5 priority-4 priority-default closed" href="/issues/22482">Feature #22482</a>: Respond with "No preview available" instead of sending the file when no preview is available</i> added</li></ul> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=708082016-05-08T08:14:37ZGo MAEDA
<ul></ul><p>@Gregor, could you please provide rebased version of these patches?</p>
<p>I am very interested in this feature but patches cannot be applied to the current trunk.</p> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=708332016-05-09T09:09:06ZGregor Schmidtschmidt@nach-vorne.eu
<ul><li><strong>File</strong> <a href="/attachments/15962">0001-Don-t-force-download-of-PDFs-but-show-in-browser-pre.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/15962/0001-Don-t-force-download-of-PDFs-but-show-in-browser-pre.patch">0001-Don-t-force-download-of-PDFs-but-show-in-browser-pre.patch</a> added</li><li><strong>File</strong> <a href="/attachments/15963">0002-Show-pdf-preview-for-repository-files-and-attachment.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/15963/0002-Show-pdf-preview-for-repository-files-and-attachment.patch">0002-Show-pdf-preview-for-repository-files-and-attachment.patch</a> added</li></ul><p>Updated patches to <a class="changeset" title="Japanese translation for "last name" and "first name" changed by Go MAEDA (#22724)" href="https://www.redmine.org/projects/redmine/repository/svn/revisions/15404">r15404</a>.</p> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=708352016-05-09T09:40:31ZGo MAEDA
<ul><li><strong>File</strong> <a href="/attachments/15964">safari-error.png</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/15964/safari-error.png">safari-error.png</a> added</li></ul><p>Thanks for updating patches.<br />But in my environemnt, I cannot view PDF in browsers. I tried two web servers, Pow 0.5.0 and Webrick, both failed.</p>
<p><b>Error:</b><br /><img src="https://www.redmine.org/attachments/download/15964/safari-error.png" alt="" /></p>
<p><b>HTTP Response header:</b></p>
<p>Content-Type is <code>binary/octet-stream</code>. Perhaps it causes this problem.</p>
<pre>
HTTP/1.1 200 OK
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
ETag: "13891eae2aa4115e138138ea507d1fdf"
Content-Disposition: inline; filename="aaaaaaa-40.pdf"
Content-Transfer-Encoding: binary
Content-Type: binary/octet-stream
Cache-Control: private
Content-Length: 8331
X-Request-Id: ef5b1ea8-cb19-4cfa-8db2-1aac427b0b1e
X-Runtime: 0.025105
Date: Mon, 09 May 2016 09:17:53 GMT
Connection: keep-alive
</pre> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=708362016-05-09T10:08:59ZGregor Schmidtschmidt@nach-vorne.eu
<ul></ul><p>I'm sorry, but I cannot reproduce your problems. I've tried Firefox (Mac), Safari (Mac and iOS 9 Simulator) on Webrick, Unicorn and Puma. In any case, the <code>Content-Type</code> was <code>application/pdf</code>, which is determined by the <code>detect_content_type</code> method within the <code>AttachmentsController</code>. Maybe you could try debugging there to find out, what happened.</p>
<p>I have also tested the changes on IE w/o Adobe Reader installed, i.e. it cannot render PDFs within the browser. It didn't give me an error but downloaded the file instead. So I was rather confident, that there should be no negative side effects when sending PDFs with <code>Content-Disposition: inline</code>.</p> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=708372016-05-09T15:04:59ZGo MAEDA
<ul></ul><p>Thanks for investigating the problem I wrote in <a class="issue tracker-2 status-10 priority-4 priority-default" title="Feature: Show PDF attachments and repo entries instead of downloading them (Needs feedback)" href="https://www.redmine.org/issues/22483#note-5">#22483#note-5</a>.</p>
<p>I found that no problem in your patches, it is caused by files which are uploaded by Firefox. Attachment#content_type of these files are 'binary/octet-stream', so 'Content-Type' field in response header will be 'binary/octet-stream'. Maybe related to <a class="external" href="https://bugzilla.mozilla.org/show_bug.cgi?id=373621">https://bugzilla.mozilla.org/show_bug.cgi?id=373621</a> .</p>
<pre>
2.2.4 :004 > Attachment.find(43).content_type
Attachment Load (0.2ms) SELECT "attachments".* FROM "attachments" WHERE "attachments"."id" = ? LIMIT 1 [["id", 43]]
=> "binary/octet-stream"
</pre>
<p>The patch works fine with files uploaded by Chrome and Safari. This feature is extremely beneficial for users who handle PDF files frequently.</p> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=708402016-05-09T16:05:39ZGo MAEDA
<ul><li><strong>File</strong> <a href="/attachments/15965">060719210727_example.pdf</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/15965/060719210727_example.pdf">060719210727_example.pdf</a> added</li></ul><p>Although the patches works fine, but test fails because PDF file "test/fixtures/files/2006/07/060719210727_example.pdf" does not exist.</p>
<pre>
$ ruby test/functional/attachments_controller_test.rb
(snip)
1) Failure:
AttachmentsControllerTest#test_show_pdf [test/functional/attachments_controller_test.rb:204]:
Expected response to be a <success>, but was <404>
</pre>
<p>log/test.log:<br /><pre>
----------------------------------------
AttachmentsControllerTest: test_show_pdf
----------------------------------------
Processing by AttachmentsController#show as HTML
Parameters: {"id"=>"21"}
(snip)
Cannot send attachment, /*****/redmine-trunk/test/fixtures/files/2006/07/060719210727_example.pdf does not exist or is unreadable.
(snip)
Completed 404 Not Found in 26ms (Views: 20.2ms | ActiveRecord: 1.0ms)
</pre></p>
<p>To pass tests, copy <a class="attachment" href="https://www.redmine.org/attachments/15966">060719210727_example.pdf</a> to test/fixtures/files/2006/07/ directory.</p> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=708412016-05-09T16:26:12ZGo MAEDA
<ul><li><strong>Assignee</strong> set to <i>Jean-Philippe Lang</i></li><li><strong>Target version</strong> set to <i>3.3.0</i></li></ul><p>@Jean-Philippe, could this feature be included in 3.3.0?</p>
<p>I know 3.3.0 is entering feature freeze but I think it would be nice if this feature is delivered along with <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Show image attachments and repo entries instead of downloading them (Closed)" href="https://www.redmine.org/issues/22058">#22058</a>.</p> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=708422016-05-09T16:53:03ZGregor Schmidtschmidt@nach-vorne.eu
<ul><li><strong>File</strong> <a href="/attachments/15966">060719210727_example.pdf</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/15966/060719210727_example.pdf">060719210727_example.pdf</a> added</li></ul><p>Go MAEDA wrote:</p>
<blockquote>
<p>Although the patches works fine, but test fails because PDF file "test/fixtures/files/2006/07/060719210727_example.pdf" does not exist.</p>
</blockquote>
<p>Sorry, I forgot to check how git's <code>format-patch</code> handles binary files. It turns out, they are omitted in the output by default.</p>
<p>Here is the example pdf, that I used locally. It's just a "Print as PDF" of <a class="external" href="http://example.org">http://example.org</a>. As you mentioned, it needs to be placed at <code>test/fixtures/files/2006/07/060719210727_example.pdf</code></p> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=708432016-05-09T16:57:48ZGregor Schmidtschmidt@nach-vorne.eu
<ul></ul><p>Concerning your problem with the wrong mime type in Firefox:</p>
<p>I am using Firefox as my main browser and also uploaded the files, that I used for testing, using Firefox. Not sure, why you would observe a different behavior.</p>
<p>Anyway, the underlying problem is, that different methods are used to determine the mime type and therefore different results may occur. The <code>disposition</code> method just checks the file ending, the <code>detect_content_type</code> tries to reuse the information passed by the browser. I assume, this should be fixed, so that only a single source is used. Maybe the introduction of the <code>mimemagic</code> gem could provide better facilities for mime handling, than those currently in place in Redmine. But this might be a topic for a separate issue.</p> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=708472016-05-10T00:19:11ZGo MAEDA
<ul><li><strong>File</strong> deleted (<del><i>0004-Don-t-force-download-of-PDFs-but-show-in-browser-pre.patch</i></del>)</li></ul> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=708482016-05-10T00:19:23ZGo MAEDA
<ul><li><strong>File</strong> deleted (<del><i>0005-Show-pdf-preview-for-repository-files-and-attachment.patch</i></del>)</li></ul> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=709702016-05-16T06:20:36ZJean-Philippe Langjp_lang@yahoo.fr
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Needs feedback</i></li></ul><p>Sending PDF inline instead of forcing the download is committed, but I'm not really sure about the preview in an iframe. I find it much less confortable than viewing it using the whole viewport of the browser. I get double scrollbars, one for the body and one for the iframe (I had to lower the height to 70vp but I guess it depens on the header and window height). Also, they're no way to zoom the content of the iframe under iOS (tested with 8) which make the preview useless.</p> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=710462016-05-21T06:48:54ZJean-Philippe Langjp_lang@yahoo.fr
<ul><li><strong>Target version</strong> deleted (<del><i>3.3.0</i></del>)</li></ul> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=711462016-05-29T12:31:14ZGo MAEDA
<ul><li><strong>Has duplicate</strong> <i><a class="issue tracker-2 status-5 priority-4 priority-default closed" href="/issues/22098">Feature #22098</a>: Open attached pdf files in the browser</i> added</li></ul> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=821072017-11-15T14:09:50ZJan from Planio www.plan.io
<ul><li><strong>Related to</strong> <i><a class="issue tracker-3 status-5 priority-4 priority-default closed" href="/issues/27336">Patch #27336</a>: Render previews for audio and video files</i> added</li></ul> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=843832018-04-05T16:25:56Zdonny osmon
<ul></ul><p>Hi, are these 2 patches for Linux (CentOS) ?<br />If so, do they work on Redmine 3.4.3.stable ?<br />Are there patch install instructions aside from "patch -p0 < the_patch.patch" ?<br />Do the patches require a restart of Redmine?<br />Thanks</p>
<p>0004-Don-t-force-download-of-PDFs-but-show-in-browser-pre.patch<br />0005-Show-pdf-preview-for-repository-files-and-attachment.patch</p> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=843842018-04-05T16:46:53Zdonny osmon
<ul></ul><p>donny osmon wrote:</p>
<blockquote>
<p>Hi, are these 2 patches for Linux (CentOS) ?<br />If so, do they work on Redmine 3.4.3.stable ?<br />Are there patch install instructions aside from "patch -p0 < the_patch.patch" ?<br />Do the patches require a restart of Redmine?<br />Does patch 0005 include patch 0004 ?<br />Thanks</p>
<p>0004-Don-t-force-download-of-PDFs-but-show-in-browser-pre.patch<br />0005-Show-pdf-preview-for-repository-files-and-attachment.patch</p>
</blockquote> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=961862020-02-10T11:18:22ZGần Sôi Nước
<ul></ul><p>Gregor Schmidt wrote:</p>
<blockquote>
<p>Updated patches to <a class="changeset" title="Japanese translation for "last name" and "first name" changed by Go MAEDA (#22724)" href="https://www.redmine.org/projects/redmine/repository/svn/revisions/15404">r15404</a>.</p>
</blockquote>
<p>Thank you!</p> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=1054032022-01-24T08:43:48ZBernhard Rohloff
<ul><li><strong>Has duplicate</strong> <i><a class="issue tracker-2 status-5 priority-4 priority-default closed" href="/issues/36504">Feature #36504</a>: PDF preview in attachment Page</i> added</li></ul> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=1069952022-06-19T15:20:31ZSteven Uggowitzer
<ul></ul><p>Has anyone updated these patches for Version 5.x ?</p> Redmine - Feature #22483: Show PDF attachments and repo entries instead of downloading themhttps://www.redmine.org/issues/22483?journal_id=1070532022-06-22T16:28:41ZSteven Uggowitzer
<ul></ul><p>Steven Uggowitzer wrote:</p>
<blockquote>
<p>Has anyone updated these patches for Version 5.x ?</p>
</blockquote>
<p>So it turns out that this actually already works in Redmine 5.x. However, for anyone trying to make it work for PDF files > 5mb, you have to actually raise the file size settings in /settings?tab=attachments to exceed the size of your PDFs. Otherwise this will not work, and you don't get a preview. Hopefully this note will help someone. All my PDFs in a repository were well over 5mb that I was testing it on, and it just didn't work for me till I realised this.</p>