Get rid of last empty page in PDFs

This commit is contained in:
wvengen 2015-01-03 00:14:38 +01:00
parent 68f56a55e5
commit d1ece157c6
3 changed files with 9 additions and 4 deletions

View file

@ -12,6 +12,8 @@ class OrderByArticles < OrderPdf
def body def body
@order.order_articles.ordered.each do |order_article| @order.order_articles.ordered.each do |order_article|
down_or_page
rows = [] rows = []
dimrows = [] dimrows = []
for goa in order_article.group_order_articles.ordered for goa in order_article.group_order_articles.ordered
@ -36,8 +38,6 @@ class OrderByArticles < OrderPdf
# dim rows which were ordered but not received # dim rows which were ordered but not received
dimrows.each { |ri| table.row(ri).text_color = '999999' } dimrows.each { |ri| table.row(ri).text_color = '999999' }
end end
down_or_page
end end
end end

View file

@ -13,6 +13,8 @@ class OrderByGroups < OrderPdf
def body def body
# Start rendering # Start rendering
@order.group_orders.ordered.each do |group_order| @order.group_orders.ordered.each do |group_order|
down_or_page 15
total = 0 total = 0
rows = [] rows = []
dimrows = [] dimrows = []
@ -53,8 +55,6 @@ class OrderByGroups < OrderPdf
# dim rows which were ordered but not received # dim rows which were ordered but not received
dimrows.each { |ri| table.row(ri).text_color = '999999' } dimrows.each { |ri| table.row(ri).text_color = '999999' }
end end
down_or_page 15
end end
end end

View file

@ -12,6 +12,7 @@ class OrderPdf < Prawn::Document
super(options) super(options)
@order = order @order = order
@options = options @options = options
@first_page = true
end end
def to_pdf def to_pdf
@ -50,6 +51,10 @@ class OrderPdf < Prawn::Document
# add pagebreak or vertical whitespace, depending on configuration # add pagebreak or vertical whitespace, depending on configuration
def down_or_page(space=10) def down_or_page(space=10)
if @first_page
@first_page = false
return
end
if pdf_add_page_breaks? if pdf_add_page_breaks?
start_new_page start_new_page
else else