Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

reset values for distributing columns on 1-page pdf

as-op344e479e4680
diff --git a/app/models/work_package/pdf_export/gantt.rb b/app/models/work_package/pdf_export/gantt.rb
index 9ebbe42fe35..9c0b5c41bcb 100644
--- a/app/models/work_package/pdf_export/gantt.rb
+++ b/app/models/work_package/pdf_export/gantt.rb
@@ -70,9 +70,7 @@ module WorkPackage::PDFExport::Gantt
@pdf = pdf
@title = title
@column_width = column_width
- @header_row_height = 30
- @text_column_width = @pdf.bounds.width / 4
- @nr_columns = (@pdf.bounds.width / @column_width).floor
+ init_defaults
end
def build(work_packages)
@@ -80,7 +78,7 @@ module WorkPackage::PDFExport::Gantt
pages = build_pages(work_packages)
# if there are not enough columns for even the first page of horizontal pages => distribute space to all columns
if pages.find { |page| page[:text_column].nil? }.nil?
- distribute_to_first_page
+ distribute_to_first_page(pages)
pages = build_pages(work_packages)
end
pages
@@ -88,6 +86,12 @@ module WorkPackage::PDFExport::Gantt
private
+ def init_defaults
+ @header_row_height = 30
+ @text_column_width = [@pdf.bounds.width / 4, 250].min
+ @nr_columns = (@pdf.bounds.width / @column_width).floor
+ end
+
def adjust_to_pages
# distribute space right to the default column widths
distribute_to_next_page_column
@@ -117,9 +121,9 @@ module WorkPackage::PDFExport::Gantt
@text_column_width = @pdf.bounds.width - (@nr_columns_first_page * @column_width)
end
- def distribute_to_first_page
+ def distribute_to_first_page(pages)
nr_of_columns = pages.first[:columns].length
- @text_column_width = @pdf.bounds.width / 4
+ init_defaults
@column_width = (@pdf.bounds.width - @text_column_width) / nr_of_columns
@nr_columns_first_page = nr_of_columns
@nr_columns = nr_of_columns