diff --git a/pypdf/_page.py b/pypdf/_page.py index 1c77ce3ba..f7d33615e 100644 --- a/pypdf/_page.py +++ b/pypdf/_page.py @@ -69,7 +69,7 @@ from .constants import AnnotationDictionaryAttributes as ADA from .constants import ImageAttributes as IA from .constants import PageAttributes as PG -from .constants import Ressources as RES +from .constants import Resources as RES from .errors import PageSizeNotDefinedError, PdfReadError from .filters import _xobj_to_image from .generic import ( diff --git a/pypdf/_writer.py b/pypdf/_writer.py index 4dbcb5274..c7569e31e 100644 --- a/pypdf/_writer.py +++ b/pypdf/_writer.py @@ -2675,10 +2675,15 @@ def _get_filtered_outline( v = NullObject() o[NameObject("/Page")] = v if "/First" in node: - o.childs = self._get_filtered_outline(node["/First"], pages, reader) + o._filtered_children = self._get_filtered_outline( + node["/First"], pages, reader + ) else: - o.childs = [] - if not isinstance(o["/Page"], NullObject) or len(o.childs) > 0: + o._filtered_children = [] + if ( + not isinstance(o["/Page"], NullObject) + or len(o._filtered_children) > 0 + ): new_outline.append(o) node = node.get("/Next", None) return new_outline @@ -2716,7 +2721,7 @@ def _insert_filtered_outline( else: np = self._clone_outline(dest) cast(TreeObject, parent.get_object()).insert_child(np, before, self) - self._insert_filtered_outline(dest.childs, np, None) + self._insert_filtered_outline(dest._filtered_children, np, None) def close(self) -> None: """To match the functions from Merger.""" diff --git a/pypdf/constants.py b/pypdf/constants.py index 5f06a0b2f..b680aa534 100644 --- a/pypdf/constants.py +++ b/pypdf/constants.py @@ -11,6 +11,8 @@ from enum import IntFlag, auto from typing import Dict, Tuple +from ._utils import deprecate_with_replacement + class Core: """Keywords that don't quite belong anywhere else.""" @@ -127,8 +129,11 @@ def all(cls) -> "UserAccessPermissions": return cls((2**32 - 1) - cls.R1 - cls.R2) -class Ressources: - """TABLE 3.30 Entries in a resource dictionary.""" +class Resources: + """ + TABLE 3.30 Entries in a resource dictionary. + used to be Ressources + """ EXT_G_STATE = "/ExtGState" # dictionary, optional COLOR_SPACE = "/ColorSpace" # dictionary, optional @@ -140,6 +145,62 @@ class Ressources: PROPERTIES = "/Properties" # dictionary, optional +class Ressources: # deprecated + """ + Use :class: `Resources` instead. + + .. deprecated:: 5.0.0 + """ + + @classmethod # type: ignore + @property + def EXT_G_STATE(cls) -> str: + deprecate_with_replacement("Ressources", "Resources", "5.0.0") + return "/ExtGState" # dictionary, optional + + @classmethod # type: ignore + @property + def COLOR_SPACE(cls) -> str: + deprecate_with_replacement("Ressources", "Resources", "5.0.0") + return "/ColorSpace" # dictionary, optional + + @classmethod # type: ignore + @property + def PATTERN(cls) -> str: + deprecate_with_replacement("Ressources", "Resources", "5.0.0") + return "/Pattern" # dictionary, optional + + @classmethod # type: ignore + @property + def SHADING(cls) -> str: + deprecate_with_replacement("Ressources", "Resources", "5.0.0") + return "/Shading" # dictionary, optional + + @classmethod # type: ignore + @property + def XOBJECT(cls) -> str: + deprecate_with_replacement("Ressources", "Resources", "5.0.0") + return "/XObject" # dictionary, optional + + @classmethod # type: ignore + @property + def FONT(cls) -> str: + deprecate_with_replacement("Ressources", "Resources", "5.0.0") + return "/Font" # dictionary, optional + + @classmethod # type: ignore + @property + def PROC_SET(cls) -> str: + deprecate_with_replacement("Ressources", "Resources", "5.0.0") + return "/ProcSet" # array, optional + + @classmethod # type: ignore + @property + def PROPERTIES(cls) -> str: + deprecate_with_replacement("Ressources", "Resources", "5.0.0") + return "/Properties" # dictionary, optional + + class PagesAttributes: """Page Attributes, Table 6.2, Page 52.""" @@ -629,7 +690,7 @@ class AnnotationFlag(IntFlag): PageAttributes, PageLayouts, PagesAttributes, - Ressources, + Resources, StreamAttributes, TrailerKeys, TypArguments, diff --git a/pypdf/generic/_data_structures.py b/pypdf/generic/_data_structures.py index bb62c69cb..838336a16 100644 --- a/pypdf/generic/_data_structures.py +++ b/pypdf/generic/_data_structures.py @@ -1416,9 +1416,6 @@ class Destination(TreeObject): node: Optional[ DictionaryObject ] = None # node provide access to the original Object - childs: List[ - Any - ] = [] # used in PdfWriter - TODO: should be children # noqa: RUF012 def __init__( self, @@ -1426,6 +1423,8 @@ def __init__( page: Union[NumberObject, IndirectObject, NullObject, DictionaryObject], fit: Fit, ) -> None: + self._filtered_children: List[Any] = [] # used in PdfWriter + typ = fit.fit_type args = fit.fit_args