Feature #40266
openProposal to Include Direct Links to Attached Files in PDF Exports of Issues
0%
Description
I propose implementing a patch to include direct links to attached files when exporting issues to PDF format. This enhancement will improve the accessibility and usability of exported PDF documents, allowing users to easily access attached files directly from the PDF.
I will provide a patch for the proposed enhancement along with relevant tests to ensure its functionality and reliability.
Thank you for considering this improvement.
Files
Updated by Yazan Al aeddin 9 months ago
Sorry, I forgot to mention that you'll need to install this gem for the test environment: gem 'pdf-reader'.
Updated by Yazan Al aeddin 9 months ago
- File helper_diff helper_diff added
I noticed there is a slight misalignment between the links and other values on the same line. Here's a correction.
Updated by Vincent Robert 8 months ago
- File before.png before.png added
- File after.png after.png added
- Target version set to 5.1.3
I have just tested this change, and it works well.
diff --git a/lib/redmine/export/pdf/issues_pdf_helper.rb b/lib/redmine/export/pdf/issues_pdf_helper.rb
index 6a6f09437..e0cd8f967 100644
--- a/lib/redmine/export/pdf/issues_pdf_helper.rb
+++ b/lib/redmine/export/pdf/issues_pdf_helper.rb
@@ -240,7 +240,9 @@ module Redmine
issue.attachments.each do |attachment|
pdf.SetFontStyle('', 8)
- pdf.RDMCell(80, 5, attachment.filename)
+ url = send(:attachment_url, attachment, {})
+ link = link_to attachment.filename, url
+ pdf.writeHTMLCell(80, 5, pdf.GetX, pdf.GetY, link)
pdf.RDMCell(20, 5, number_to_human_size(attachment.filesize), 0, 0, "R")
pdf.RDMCell(25, 5, format_date(attachment.created_on), 0, 0, "R")
Before:
After:
By the way, we should also refactor the far too long issue_to_pdf
method, to make it more maintainable (and make it easier to patch in plugins).
Updated by Vincent Robert 8 months ago
Yes, you are right.
And on a broader scale, we could include a setting to activate all links in the generated PDFs, including links to attached files as well as links to the issue itself.