Skip to content

Commit 3a01dcf

Browse files
committed
read padding from correct box when creating new page
resolves #1121
1 parent 7b7348d commit 3a01dcf

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Unreleased
44

5+
### Apply correct margin box when creating or switching pages
6+
7+
When creating a new page or returning to a page previously created, compute the margin box correctly.
8+
9+
(Dan Allen, [#1122](https://github.com/prawnpdf/prawn/pull/1022))
10+
511
### Look for glyph in correct font
612

713
Take the font style into account when looking for a glyph and fallback fonts are enabled.

lib/prawn/document.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -723,15 +723,17 @@ def generate_margin_box
723723
(page.margins[:top] + page.margins[:bottom])
724724
)
725725

726-
# This check maintains indentation settings across page breaks
726+
# update bounding box if not flowing from the previous page
727+
unless @bounding_box&.parent
728+
old_margin_box = @bounding_box
729+
@bounding_box = @margin_box
730+
end
731+
732+
# maintains indentation settings across page breaks
727733
if old_margin_box
728734
@margin_box.add_left_padding(old_margin_box.total_left_padding)
729735
@margin_box.add_right_padding(old_margin_box.total_right_padding)
730736
end
731-
732-
# we must update bounding box if not flowing from the previous page
733-
#
734-
@bounding_box = @margin_box unless @bounding_box&.parent
735737
end
736738

737739
def apply_margin_options(options)

0 commit comments

Comments
 (0)