From d0d9608e01e74cf67353dd5c0bc56bb687a55971 Mon Sep 17 00:00:00 2001 From: Django van der Heijden <60142790+djangovanderheijden@users.noreply.github.com> Date: Tue, 1 Jul 2025 12:10:15 +0200 Subject: [PATCH] Bugfix: check whether self._info is not None before accessing its indirect_reference property --- pypdf/_writer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pypdf/_writer.py b/pypdf/_writer.py index cf50ca0bf..7dd684239 100644 --- a/pypdf/_writer.py +++ b/pypdf/_writer.py @@ -1671,7 +1671,8 @@ def replace_in_obj( # remove orphans (if applicable) orphans[self.root_object.indirect_reference.idnum - 1] = False # type: ignore - orphans[self._info.indirect_reference.idnum - 1] = False # type: ignore + if self._info is not None: + orphans[self._info.indirect_reference.idnum - 1] = False # type: ignore try: orphans[self._ID.indirect_reference.idnum - 1] = False # type: ignore