rending multiple cards per page, as defined in the config.

pull/6827/head
Richard 11 years ago
parent 945079fdf4
commit 1fa1a9a2f0
  1. 6
      app/views/taskboard_card_configurations/edit.html.erb
  2. 38
      lib/open_project/pdf_export/taskboard_card/document_generator.rb

@ -5,6 +5,12 @@
<%= f.label :page_size %> <%= f.label :page_size %>
<%= f.text_field :page_size %> <%= f.text_field :page_size %>
<br> <br>
<%= f.label :per_page %>
<%= f.text_field :per_page %>
<br>
<%= f.label :orientation %>
<%= f.text_field :orientation %>
<br>
<%= f.label :rows %> <%= f.label :rows %>
<%= f.text_area :rows %> <%= f.text_area :rows %>
<br> <br>

@ -16,7 +16,7 @@ module OpenProject::PdfExport::TaskboardCard
@config = config @config = config
@work_packages = work_packages @work_packages = work_packages
page_layout = :landscape page_layout = :landscape if config.landscape? else :portrait
page_size = config.page_size or defaults[:page_size] page_size = config.page_size or defaults[:page_size]
geom = Prawn::Document::PageGeometry::SIZES[page_size] geom = Prawn::Document::PageGeometry::SIZES[page_size]
@paper_width = geom[0] @paper_width = geom[0]
@ -37,22 +37,28 @@ module OpenProject::PdfExport::TaskboardCard
end end
def render_pages def render_pages
@work_packages.each do |wp| padding = 10
@config.per_page.times do card_width = 400
# Position and size depend on how the cards are to be arranged on the page which is not known yet card_height = ((pdf.bounds.height - (padding * @config.per_page )) / @config.per_page) - (padding / @config.per_page)
padding = 20 card_y_offset = pdf.bounds.height - padding
orientation = { @work_packages.each_with_index do |wp, i|
y_offset: pdf.bounds.height - padding, orientation = {
x_offset: padding, y_offset: card_y_offset,
width: 400, x_offset: padding,
height: 400 width: card_width,
} height: card_height
}
card_element = CardElement.new(pdf, orientation, config.rows_hash, wp)
card_element.draw card_element = CardElement.new(pdf, orientation, config.rows_hash, wp)
card_element.draw
if (i + 1) % @config.per_page == 0
pdf.start_new_page
card_y_offset = pdf.bounds.height - padding
else
card_y_offset -= (card_height + padding)
end end
pdf.start_new_page
end end
end end
end end

Loading…
Cancel
Save