diff --git a/PyPDF2/_page.py b/PyPDF2/_page.py index fcd6cb328..52863407c 100644 --- a/PyPDF2/_page.py +++ b/PyPDF2/_page.py @@ -58,6 +58,7 @@ from .constants import ImageAttributes as IA from .constants import PageAttributes as PG from .constants import Ressources as RES +from .constants import AnnotationDictionaryAttributes as ADA from .errors import PageSizeNotDefinedError from .filters import _xobj_to_image from .generic import ( @@ -1057,6 +1058,20 @@ def scale(self, sx: float, sy: float) -> None: self.bleedbox = self.bleedbox.scale(sx, sy) self.trimbox = self.trimbox.scale(sx, sy) self.mediabox = self.mediabox.scale(sx, sy) + + if PG.ANNOTS in self: + annotations = self[PG.ANNOTS] + if isinstance(annotations, ArrayObject): + for annotation in annotations: + annotation_obj = annotation.get_object() + if ADA.Rect in annotation_obj: + rectangle = annotation_obj[ADA.Rect] + if isinstance(rectangle, ArrayObject): + rectangle[0] = FloatObject(float(rectangle[0]) * sx) + rectangle[1] = FloatObject(float(rectangle[1]) * sy) + rectangle[2] = FloatObject(float(rectangle[2]) * sx) + rectangle[3] = FloatObject(float(rectangle[3]) * sy) + if PG.VP in self: viewport = self[PG.VP] if isinstance(viewport, ArrayObject):