From 7a4c52362c6d7b6371840cf8d711ed13659e9622 Mon Sep 17 00:00:00 2001 From: Jens Kraemer Date: Tue, 24 Aug 2021 15:02:49 +0800 Subject: [PATCH] interpret thumbnail macro in description, notes and formatted custom fields in issues list PDF export --- lib/redmine/export/pdf.rb | 4 +++ lib/redmine/export/pdf/issues_pdf_helper.rb | 40 +++++++++++---------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/lib/redmine/export/pdf.rb b/lib/redmine/export/pdf.rb index 7e6252b3f..cba4167b4 100644 --- a/lib/redmine/export/pdf.rb +++ b/lib/redmine/export/pdf.rb @@ -104,6 +104,10 @@ module Redmine atta = RDMPdfEncoding.attach(@attachments, attrname, "UTF-8") if atta return atta.diskfile + elsif %r{/attachments/download/(?[^/]+)/} =~ attrname and + atta = @attachments.find{|a| a.id.to_s == id} and + atta.readable? and atta.visible? + return atta.diskfile elsif %r{/attachments/thumbnail/(?[^/]+)/(?\d+)} =~ attrname and atta = @attachments.find{|a| a.id.to_s == id} and atta.readable? and atta.visible? diff --git a/lib/redmine/export/pdf/issues_pdf_helper.rb b/lib/redmine/export/pdf/issues_pdf_helper.rb index 98c7347ab..7fda6ad36 100644 --- a/lib/redmine/export/pdf/issues_pdf_helper.rb +++ b/lib/redmine/export/pdf/issues_pdf_helper.rb @@ -122,14 +122,7 @@ module Redmine # Set resize image scale pdf.set_image_scale(1.6) - text = - textilizable( - issue, :description, - :only_path => false, - :edit_section_links => false, - :headings => false, - :inline_attachments => false - ) + text = pdf_format_text(issue, :description) pdf.RDMwriteFormattedCell(35+155, 5, '', '', text, issue.attachments, "LRB") custom_field_values = issue.visible_custom_field_values.select {|value| value.custom_field.full_width_layout?} @@ -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 @@ -347,14 +333,17 @@ module Redmine pdf.set_y(base_y + max_height) query.block_columns.each do |column| + is_html = false if column.is_a?(QueryCustomFieldColumn) cv = issue.visible_custom_field_values.detect do |v| v.custom_field_id == column.custom_field.id end - text = show_value(cv, false) + is_html = cv.custom_field.full_text_formatting? + text = show_value(cv, is_html) else - text = issue.send(column.name) + text = pdf_format_text issue, column.name.to_sym + is_html = true end next if text.blank? @@ -363,7 +352,11 @@ module Redmine pdf.SetFontStyle('B', 9) pdf.RDMCell(0, 5, column.caption, "LRT", 1) pdf.SetFontStyle('', 9) - pdf.RDMwriteHTMLCell(0, 5, '', '', text, [], "LRB") + if is_html + pdf.RDMwriteFormattedCell(0, 5, '', '', text, issue.attachments, "LRB") + else + pdf.RDMwriteHTMLCell(0, 5, '', '', text, [], "LRB") + end pdf.set_auto_page_break(false) end end @@ -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' -- 2.20.1