allow to set page break options for each document
This commit is contained in:
parent
72709be60a
commit
790a6b1972
2 changed files with 21 additions and 1 deletions
|
@ -83,6 +83,11 @@ default: &defaults
|
|||
# Some documents (like group and article PDFs) can include page breaks
|
||||
# after each sublist.
|
||||
#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: <a href="http://www.foodcoop.test/">FC Test</a> is supported by <a href="http://www.hoster.test/">Hoster</a>.
|
||||
|
|
|
@ -50,10 +50,25 @@ class OrderPdf < Prawn::Document
|
|||
|
||||
# add pagebreak or vertical whitespace, depending on configuration
|
||||
def down_or_page(space=10)
|
||||
if FoodsoftConfig[:pdf_add_page_breaks]
|
||||
if pdf_add_page_breaks?
|
||||
start_new_page
|
||||
else
|
||||
move_down space
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue