Skip to content
Open
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
14 changes: 11 additions & 3 deletions rmrl/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,17 @@ def merge_pages(basepage, rmpage, changed_page, expand_pages):
# MediaBox, so one must be taken from the parent. The
# rM adds a bit to the width AND the height on this
# file.
bpage_box = list(map(float, basepage.CropBox
or basepage.MediaBox
or basepage.Parent.MediaBox))
# Sometimes the direct parent does not have a MediaBox.
# In this situation, look one extra level above.
box_data = basepage.CropBox or basepage.MediaBox or basepage.Parent.MediaBox
if not box_data and hasattr(basepage.Parent,'Parent'):
box_data = basepage.Parent.Parent.MediaBox

# If we still can't find it, raise an exception that describes the problem
if not box_data:
raise TypeError("Could not find the dimensions of the base PDF page.")

bpage_box = list(map(float, box_data))

# Fix any malformed PDF that has a CropBox extending outside of
# the MediaBox, by limiting the area to the intersection.
Expand Down