Skip to content

Commit 3326cb7

Browse files
BUG: Avoid scaling cropbox twice (#1314)
When a PDF document has no crobox, artbox, etc, they are fallback to mediabox. As they are lazy, self.cropbox returns the mediabox copy which already was scaled. Changing the order avoids this issue
1 parent a9fe98d commit 3326cb7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

PyPDF2/_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,11 +952,11 @@ def scale(self, sx: float, sy: float) -> None:
952952
:param float sy: The scaling factor on vertical axis.
953953
"""
954954
self.add_transformation((sx, 0, 0, sy, 0, 0))
955-
self.mediabox = self.mediabox.scale(sx, sy)
956955
self.cropbox = self.cropbox.scale(sx, sy)
957956
self.artbox = self.artbox.scale(sx, sy)
958957
self.bleedbox = self.bleedbox.scale(sx, sy)
959958
self.trimbox = self.trimbox.scale(sx, sy)
959+
self.mediabox = self.mediabox.scale(sx, sy)
960960
if PG.VP in self:
961961
viewport = self[PG.VP]
962962
if isinstance(viewport, ArrayObject):

0 commit comments

Comments
 (0)