Feature #35683

PDF rendering improvements when exporting an issue or a list of issues

Added by Jens Krämer about 1 year ago. Updated 6 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Marius BALTEANU% Done:

0%

Category:PDF export
Target version:5.0.0
Resolution:

Description

Two PDF generation improvements:

1. Currently, when rendering an issue PDF, macros are only expanded in the description, but not when rendering custom fields with fulltext formatting enabled. The patch changes the behaviour so that formatted full-width custom fields are rendered in the same way the description is rendered, fully interpreting macros. The behaviour for rendering normal-width custom fields is unchanged, probably it is better to leave it as is due to space constraints.
2. Thumbnail macro output was not rendered properly (in the issue description and elsewhere) because the thumbnail image file could not be retrieved - the second patch extends get_image_filename to check for thumbnail URLs and retrieve the proper file path in that case.

Both patches were initially developed for Planio .

0001-retrieve-filenames-of-thumbnails-when-rendering-a-PD.patch Magnifier (935 Bytes) Jens Krämer, 2021-08-04 12:50

0001-render-formatted-full-width-custom-fields-in-the-sam.patch Magnifier (1.53 KB) Jens Krämer, 2021-08-04 12:50

0001-interpret-thumbnail-macro-in-description-notes-and-f.patch Magnifier (4.46 KB) Jens Krämer, 2021-08-25 11:51


Related issues

Related to Redmine - Defect #34709: No Images in PDF export of issue list (with option show d... Closed

Associated revisions

Revision 21211
Added by Marius BALTEANU about 1 year ago

Expand macros in full-width custom fields when exporting issue to PDF (#35683).

Patch by Jens Krämer.

Revision 21212
Added by Marius BALTEANU about 1 year ago

Retrieve filenames of thumbnails when rendering a PDF (#35683).

Patch by Jens Krämer.

Revision 21213
Added by Marius BALTEANU about 1 year ago

Interpret thumbnail macro in description, notes and formatted custom fields in issues list PDF export (35683).

Patch by Jens Krämer.

Revision 21219
Added by Marius BALTEANU about 1 year ago

Disable Lint/DuplicateBranch in lib/redmine/export/pdf.rb#107 (#35683).

Revision 21220
Added by Marius BALTEANU about 1 year ago

Fix Layout/ClosingParenthesisIndentation offense (#35683).

History

#1 Updated by Mischa The Evil about 1 year ago

  • Target version set to Candidate for next minor release

Nice improvements.

#2 Updated by Go MAEDA about 1 year ago

  • Target version changed from Candidate for next minor release to 5.0.0

Setting the target version to 5.0.0.

#3 Updated by Jens Krämer about 1 year ago

  • File 0001-interpret-thumbnail-macro-in-description-notes-and-f.patch added

One more patch (based on the first two) which introduces the full rendering of last notes, description and formatted full width custom fields for the tabular issues list PDF export.

#4 Updated by Mischa The Evil about 1 year ago

  • Status changed from New to Needs feedback
  • Assignee set to Jens Krämer

Jens Krämer wrote:

One more patch (based on the first two) [...]

Jens, I have only read the patch, but it seems to contain an error/typo. Shouldn't:

diff --git a/lib/redmine/export/pdf/issues_pdf_helper.rb b/lib/redmine/export/pdf/issues_pdf_helper.rb
index 98c7347ab..f55c80f5c 100644
--- a/lib/redmine/export/pdf/issues_pdf_helper.rb
+++ b/lib/redmine/export/pdf/issues_pdf_helper.rb
@@ -232,14 +225,7 @@ module Redmine
               if journal.notes?
                 pdf.ln unless journal.details.empty?
                 pdf.SetFontStyle('', 8)
-                text =
-                  textilizable(
-                    journal, :notes,
-                    :only_path => false,
-                    :edit_section_links => false,
-                    :headings => false,
-                    :inline_attachments => false
-                  )
+                text = pdf_format_text(issue, :description)
                 pdf.RDMwriteFormattedCell(190, 5, '', '', text, issue.attachments, "")
               end
               pdf.ln

actually be:

diff --git a/lib/redmine/export/pdf/issues_pdf_helper.rb b/lib/redmine/export/pdf/issues_pdf_helper.rb
index 98c7347ab..f55c80f5c 100644
--- a/lib/redmine/export/pdf/issues_pdf_helper.rb
+++ b/lib/redmine/export/pdf/issues_pdf_helper.rb
@@ -232,14 +225,7 @@ module Redmine
               if journal.notes?
                 pdf.ln unless journal.details.empty?
                 pdf.SetFontStyle('', 8)
-                text =
-                  textilizable(
-                    journal, :notes,
-                    :only_path => false,
-                    :edit_section_links => false,
-                    :headings => false,
-                    :inline_attachments => false
-                  )
+                text = pdf_format_text(journal, :notes)
                 pdf.RDMwriteFormattedCell(190, 5, '', '', text, issue.attachments, "")
               end
               pdf.ln

If so, then I think pdf_format_text would be better defined as something along the lines of:

diff --git a/lib/redmine/export/pdf/issues_pdf_helper.rb b/lib/redmine/export/pdf/issues_pdf_helper.rb
index 98c7347ab..f55c80f5c 100644
--- a/lib/redmine/export/pdf/issues_pdf_helper.rb
+++ b/lib/redmine/export/pdf/issues_pdf_helper.rb
@@ -375,6 +368,15 @@ module Redmine
           pdf.output
         end

+        def pdf_format_text(object, attribute)
+          textilizable(object, attribute,
+                       :only_path => false,
+                       :edit_section_links => false,
+                       :headings => false,
+                       :inline_attachments => false
+                      )
+        end
+
         def is_cjk?
           case current_language.to_s.downcase
           when 'ja', 'zh-tw', 'zh', 'ko'

#5 Updated by Jens Krämer about 1 year ago

  • File 0001-interpret-thumbnail-macro-in-description-notes-and-f.patch added

you're completely right, I attached an updated patch.

#7 Updated by Mischa The Evil about 1 year ago

  • File deleted (0001-interpret-thumbnail-macro-in-description-notes-and-f.patch)

#8 Updated by Mischa The Evil about 1 year ago

  • File deleted (0001-interpret-thumbnail-macro-in-description-notes-and-f.patch)

#9 Updated by Mischa The Evil about 1 year ago

  • Status changed from Needs feedback to New
  • Assignee deleted (Jens Krämer)

Jens, thanks for the update. I've removed the faulty files to keep it clear.

@committers: the correct order of the patchset is:
  1. 0001-render-formatted-full-width-custom-fields-in-the-sam.patch
  2. 0001-retrieve-filenames-of-thumbnails-when-rendering-a-PD.patch
  3. 0001-interpret-thumbnail-macro-in-description-notes-and-f.patch

#10 Updated by Marius BALTEANU about 1 year ago

  • Status changed from New to Resolved
  • Assignee set to Marius BALTEANU

All three patches committed, thanks for the nice improvements.

#11 Updated by Marius BALTEANU about 1 year ago

  • Subject changed from PDF rendering improvements to PDF rendering improvements when exporting an issue or a list of issues

#12 Updated by Marius BALTEANU about 1 year ago

  • Status changed from Resolved to Closed

#13 Updated by Go MAEDA 9 months ago

  • Related to Defect #34709: No Images in PDF export of issue list (with option show description) added

#14 Updated by Go MAEDA 6 months ago

  • Tracker changed from Patch to Feature

Also available in: Atom PDF