Skip to content

Commit 427a0f9

Browse files
committed
read padding from correct box when creating new page
resolves prawnpdf#1121
1 parent 62f5f4a commit 427a0f9

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
## PrawnPDF master branch
22

3+
## Unreleased
4+
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+
311
## PrawnPDF 2.3.0
412

513
### Added OpenType Font Support

lib/prawn/document.rb

+7-5
Original file line numberDiff line numberDiff line change
@@ -720,15 +720,17 @@ def generate_margin_box
720720
(page.margins[:top] + page.margins[:bottom])
721721
)
722722

723-
# This check maintains indentation settings across page breaks
723+
# update bounding box if not flowing from the previous page
724+
unless @bounding_box&.parent
725+
old_margin_box = @bounding_box
726+
@bounding_box = @margin_box
727+
end
728+
729+
# maintains indentation settings across page breaks
724730
if old_margin_box
725731
@margin_box.add_left_padding(old_margin_box.total_left_padding)
726732
@margin_box.add_right_padding(old_margin_box.total_right_padding)
727733
end
728-
729-
# we must update bounding box if not flowing from the previous page
730-
#
731-
@bounding_box = @margin_box unless @bounding_box&.parent
732734
end
733735

734736
def apply_margin_options(options)

0 commit comments

Comments
 (0)