From 2e908386e0703f211bcf10129345b4a4dfef4e76 Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Fri, 10 Feb 2023 23:03:25 +0100 Subject: [PATCH] ENH: Make used cropbox configurable --- pypdf/__init__.py | 2 ++ pypdf/_page.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pypdf/__init__.py b/pypdf/__init__.py index 3ddd264f1e..83c1d82fe8 100644 --- a/pypdf/__init__.py +++ b/pypdf/__init__.py @@ -16,6 +16,8 @@ from .pagerange import PageRange, parse_filename_page_ranges from .papersizes import PaperSize +MERGE_CROP_BOX = "cropbox" # pypdf<=3.4.0 used 'trimbox' + __all__ = [ "__version__", "PageRange", diff --git a/pypdf/_page.py b/pypdf/_page.py index 80d98287bd..892a23e790 100644 --- a/pypdf/_page.py +++ b/pypdf/_page.py @@ -44,6 +44,7 @@ cast, ) +from . import MERGE_CROP_BOX from ._cmap import build_char_map, unknown_char_map from ._protocols import PdfReaderProtocol, PdfWriterProtocol from ._utils import ( @@ -844,7 +845,7 @@ def _merge_page( page2content = page2.get_contents() if page2content is not None: page2content = ContentStream(page2content, self.pdf) - rect = page2.trimbox + rect = getattr(page2, MERGE_CROP_BOX) page2content.operations.insert( 0, ( @@ -972,7 +973,7 @@ def _merge_page_writer( page2content = page2.get_contents() if page2content is not None: page2content = ContentStream(page2content, self.pdf) - rect = page2.trimbox + rect = getattr(page2, MERGE_CROP_BOX) page2content.operations.insert( 0, (