From 1eb7e208274dd138d60f91d477b6f37eef03e820 Mon Sep 17 00:00:00 2001 From: Eric Hankins Date: Thu, 22 Dec 2016 10:59:46 -0600 Subject: [PATCH 1/2] Fix specific document margin options --- lib/prawn/document.rb | 2 +- spec/prawn/document_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/prawn/document.rb b/lib/prawn/document.rb index a611a6f5b..21b477066 100644 --- a/lib/prawn/document.rb +++ b/lib/prawn/document.rb @@ -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 diff --git a/spec/prawn/document_spec.rb b/spec/prawn/document_spec.rb index 497fd244d..871c9108b 100644 --- a/spec/prawn/document_spec.rb +++ b/spec/prawn/document_spec.rb @@ -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 From 3925f60387f6499f905d3e4041c21fc27a1ccc24 Mon Sep 17 00:00:00 2001 From: Eric Hankins Date: Thu, 22 Dec 2016 11:00:33 -0600 Subject: [PATCH 2/2] Add final_gap back to Formatted::Box This fixes a problem where table headers with valign: bottom were too close to the bottom border. --- lib/prawn/text/formatted/box.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/prawn/text/formatted/box.rb b/lib/prawn/text/formatted/box.rb index 352116edc..d7ff0a1ab 100644 --- a/lib/prawn/text/formatted/box.rb +++ b/lib/prawn/text/formatted/box.rb @@ -161,6 +161,7 @@ def initialize(formatted_text, options = {}) @align = options[:align] || (@direction == :rtl ? :right : :left) @vertical_align = options[:valign] || :top + @final_gap = options[:final_gap] @leading = options[:leading] || @document.default_leading @character_spacing = options[:character_spacing] || @document.character_spacing @@ -341,7 +342,7 @@ def valid_options PDF::Core::Text::VALID_OPTIONS + [ :at, :height, :width, - :align, :valign, + :align, :valign, :final_gap, :rotate, :rotate_around, :overflow, :min_font_size, :disable_wrap_by_char, @@ -507,6 +508,7 @@ def process_vertical_alignment(text) @at[1] -= (@height - height + @descender) * 0.5 when :bottom @at[1] -= (@height - height) + @at[1] += line_gap if @final_gap end @height = height