Project

General

Profile

Actions

Feature #40266

open

Proposal to Include Direct Links to Attached Files in PDF Exports of Issues

Added by Yazan Al aeddin 9 months ago. Updated 7 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
PDF export
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:

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

helper.diff (1005 Bytes) helper.diff Yazan Al aeddin, 2024-02-19 14:27
issues_pdf_redmine_helper_test.rb (749 Bytes) issues_pdf_redmine_helper_test.rb Yazan Al aeddin, 2024-02-19 14:27
helper_diff (1.05 KB) helper_diff Yazan Al aeddin, 2024-03-04 10:33
before.png (121 KB) before.png Vincent Robert, 2024-04-03 15:32
after.png (170 KB) after.png Vincent Robert, 2024-04-03 15:32
Actions #1

Updated by Vincent Robert 8 months ago

  • Category set to PDF export
Actions #2

Updated by Yazan Al aeddin 8 months ago

Sorry, I forgot to mention that you'll need to install this gem for the test environment: gem 'pdf-reader'.

Actions #3

Updated by Yazan Al aeddin 8 months ago

I noticed there is a slight misalignment between the links and other values on the same line. Here's a correction.

Actions #4

Updated by Vincent Robert 7 months ago

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).

Actions #5

Updated by Go MAEDA 7 months ago

I think this feature should be able to be disabled if necessary. This is because it is not uncommon for people to not want outsiders to know their organization's Redmine URL.

Actions #6

Updated by Marius BÄ‚LTEANU 7 months ago

  • Target version deleted (5.1.3)
Actions #7

Updated by Vincent Robert 7 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.

Actions

Also available in: Atom PDF