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

View file

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

View file

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