allow to set page break options for each document

This commit is contained in:
wvengen 2014-08-28 08:10:57 +02:00
parent 72709be60a
commit 790a6b1972
2 changed files with 21 additions and 1 deletions

View file

@ -83,6 +83,11 @@ default: &defaults
# Some documents (like group and article PDFs) can include page breaks # Some documents (like group and article PDFs) can include page breaks
# after each sublist. # after each sublist.
#pdf_add_page_breaks: true #pdf_add_page_breaks: true
# Alternatively, this can be set for each document.
#pdf_add_page_breaks:
# order_by_groups: true
# order_by_articles: true
# Page footer (html allowed). Default is a Foodsoft footer. Set to `blank` for no footer. # Page footer (html allowed). Default is a Foodsoft footer. Set to `blank` for no footer.
#page_footer: <a href="http://www.foodcoop.test/">FC Test</a> is supported by <a href="http://www.hoster.test/">Hoster</a>. #page_footer: <a href="http://www.foodcoop.test/">FC Test</a> is supported by <a href="http://www.hoster.test/">Hoster</a>.

View file

@ -50,10 +50,25 @@ 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 FoodsoftConfig[:pdf_add_page_breaks] if pdf_add_page_breaks?
start_new_page start_new_page
else else
move_down space move_down space
end end
end end
protected
# return whether pagebreak or vertical whitespace is used for breaks
def pdf_add_page_breaks?(docid=nil)
docid ||= self.class.name.underscore
cfg = FoodsoftConfig[:pdf_add_page_breaks]
if cfg.is_a? Array
cfg.index(docid.to_s).any?
elsif cfg.is_a? Hash
cfg[docid.to_s]
else
cfg
end
end
end end