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.text_field :page_size %>
<br>
<%= f.label :per_page %>
<%= f.text_field :per_page %>
<br>
<%= f.label :orientation %>
<%= f.text_field :orientation %>
<br>
<%= f.label :rows %>
<%= f.text_area :rows %>
<br>

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

Loading…
Cancel
Save