Skip to content

Commit

Permalink
Fix specific document margin options
Browse files Browse the repository at this point in the history
  • Loading branch information
stormsilver committed Feb 16, 2017
1 parent 631331f commit af8afb9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/prawn/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def apply_margin_options(options)
}[margin.length]

sides.zip(positions).each do |side, pos|
new_margin = options["#{side}_margin"] || (margin[pos] if pos)
new_margin = options[:"#{side}_margin"] || (margin[pos] if pos)
state.page.margins[side] = new_margin if new_margin
end
end
Expand Down
6 changes: 6 additions & 0 deletions spec/prawn/document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ def self.format(string)
described_class.new.start_new_page({ margin: 0 }.freeze)
end.to_not raise_error
end

it "it sets individual page margins" do
doc = described_class.new
doc.start_new_page({ top_margin: 42 })
expect(doc.page.margins[:top]).to eq(42)
end
end

describe '#page_number' do
Expand Down

0 comments on commit af8afb9

Please sign in to comment.