Headers and table improvements for matrix pdf. Fixed #204

This commit is contained in:
Benjamin Meichsner 2009-04-03 18:58:12 +02:00
parent 578002501b
commit de1aa2ac38

View file

@ -35,6 +35,9 @@ while (page_number * max_order_articles_per_page < total_num_order_articles) do
page_number += 1
pdf.start_new_page(:layout => :landscape)
pdf.header [pdf.margin_box.left,pdf.margin_box.top+20] do
pdf.text title, :size => 10, :align => :center
end
# Collect order_articles for this page
current_order_articles = order_articles.select do |a|
@ -45,7 +48,7 @@ while (page_number * max_order_articles_per_page < total_num_order_articles) do
# Make order_articles header
header = [""]
for header_article in current_order_articles
name = header_article.article.name.split("-").join(" ").split(".").join(". ").split("/").join(" ")
name = header_article.article.name.gsub(/[-\/]/, " ").gsub(".", ". ")
name = name.split.collect { |w| truncate(w, :length => 8, :omission => "..") }.join(" ")
header << truncate(name, :length => 30, :omission => " ..")
end
@ -65,14 +68,15 @@ while (page_number * max_order_articles_per_page < total_num_order_articles) do
end
# Make table
widths = { } # Generate widths-hash for table layout
(max_order_articles_per_page + 1).times { |i| widths.merge!({ i => 40 }) unless i == 0 }
widths = {0 => 85} # Generate widths-hash for table layout
(max_order_articles_per_page + 1).times { |i| widths.merge!({ i => 41 }) unless i == 0 }
logger.debug "Spaltenbreiten: #{widths.inspect}"
pdf.table groups_data,
:font_size => 8,
:border_style => :grid,
:vertical_padding => 3,
:headers => header,
:widths => widths,
:column_widths => widths,
:row_colors => ['ffffff','ececec']
end