Skip to content

Commit

Permalink
read padding from correct box when creating new page
Browse files Browse the repository at this point in the history
resolves prawnpdf#1121
  • Loading branch information
mojavelinux committed Aug 25, 2020
1 parent 62f5f4a commit 427a0f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
## PrawnPDF master branch

## Unreleased

### Apply correct margin box when creating or switching pages

When creating a new page or returning to a page previously created, compute the margin box correctly.

(Dan Allen, [#1122](https://github.com/prawnpdf/prawn/pull/1022))

## PrawnPDF 2.3.0

### Added OpenType Font Support
Expand Down
12 changes: 7 additions & 5 deletions lib/prawn/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -720,15 +720,17 @@ def generate_margin_box
(page.margins[:top] + page.margins[:bottom])
)

# This check maintains indentation settings across page breaks
# update bounding box if not flowing from the previous page
unless @bounding_box&.parent
old_margin_box = @bounding_box
@bounding_box = @margin_box
end

# maintains indentation settings across page breaks
if old_margin_box
@margin_box.add_left_padding(old_margin_box.total_left_padding)
@margin_box.add_right_padding(old_margin_box.total_right_padding)
end

# we must update bounding box if not flowing from the previous page
#
@bounding_box = @margin_box unless @bounding_box&.parent
end

def apply_margin_options(options)
Expand Down

0 comments on commit 427a0f9

Please sign in to comment.