Skip to content

Commit d89fb78

Browse files
authored
MAINT: Tweak class PageObject (#3266)
Remove a redundant comment and modify some other comments. Reorder page boundaries to familiar order.
1 parent 537dd18 commit d89fb78

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

pypdf/_page.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,6 @@ def __init__(
508508
DictionaryObject.__init__(self)
509509
self.pdf = pdf
510510
self.inline_images: Optional[Dict[str, ImageFile]] = None
511-
# below Union for mypy but actually Optional[List[str]]
512511
self.indirect_reference = indirect_reference
513512
if not is_null_or_none(indirect_reference):
514513
assert indirect_reference is not None, "mypy"
@@ -1116,11 +1115,11 @@ def merge_page(
11161115
"""
11171116
Merge the content streams of two pages into one.
11181117
1119-
Resource references
1120-
(i.e. fonts) are maintained from both pages. The mediabox/cropbox/etc
1121-
of this page are not altered. The parameter page's content stream will
1122-
be added to the end of this page's content stream, meaning that it will
1123-
be drawn after, or "on top" of this page.
1118+
Resource references (e.g. fonts) are maintained from both pages.
1119+
The mediabox, cropbox, etc of this page are not altered.
1120+
The parameter page's content stream will
1121+
be added to the end of this page's content stream,
1122+
meaning that it will be drawn after, or "on top" of this page.
11241123
11251124
Args:
11261125
page2: The page to be merged into this one. Should be
@@ -1569,31 +1568,28 @@ def add_transformation(
15691568
for i in range(0, 8, 2)
15701569
]
15711570

1572-
lowerleft = (min(new_x), min(new_y))
1573-
upperright = (max(new_x), max(new_y))
1574-
1575-
self.mediabox.lower_left = lowerleft
1576-
self.mediabox.upper_right = upperright
1571+
self.mediabox.lower_left = (min(new_x), min(new_y))
1572+
self.mediabox.upper_right = (max(new_x), max(new_y))
15771573

15781574
def scale(self, sx: float, sy: float) -> None:
15791575
"""
15801576
Scale a page by the given factors by applying a transformation matrix
15811577
to its content and updating the page size.
15821578
1583-
This updates the mediabox, the cropbox, and the contents
1584-
of the page.
1579+
This updates the various page boundaries (mediabox, cropbox, etc.)
1580+
and the contents of the page.
15851581
15861582
Args:
15871583
sx: The scaling factor on horizontal axis.
15881584
sy: The scaling factor on vertical axis.
15891585
15901586
"""
15911587
self.add_transformation((sx, 0, 0, sy, 0, 0))
1588+
self.mediabox = self.mediabox.scale(sx, sy)
15921589
self.cropbox = self.cropbox.scale(sx, sy)
1593-
self.artbox = self.artbox.scale(sx, sy)
15941590
self.bleedbox = self.bleedbox.scale(sx, sy)
15951591
self.trimbox = self.trimbox.scale(sx, sy)
1596-
self.mediabox = self.mediabox.scale(sx, sy)
1592+
self.artbox = self.artbox.scale(sx, sy)
15971593

15981594
if PG.ANNOTS in self:
15991595
annotations = self[PG.ANNOTS]

0 commit comments

Comments
 (0)