Skip to content

Commit

Permalink
allow to set page break options for each document
Browse files Browse the repository at this point in the history
  • Loading branch information
wvengen committed Aug 29, 2014
1 parent 72709be commit 790a6b1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config/app_config.yml.SAMPLE
Original file line number Diff line number Diff line change
Expand Up @@ -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>.
Expand Down
17 changes: 16 additions & 1 deletion lib/order_pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,25 @@ def fontsize(n)

# 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

0 comments on commit 790a6b1

Please sign in to comment.