Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix table headers #1003

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 3 additions & 1 deletion lib/prawn/text/formatted/box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
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