From 6434e0fe5dbee0a733c8bec1c777aeb0ac7faf37 Mon Sep 17 00:00:00 2001 From: Lucas Cimon <925560+Lucas-C@users.noreply.github.com> Date: Fri, 26 Sep 2025 12:56:36 +0200 Subject: [PATCH] BUG: Fix a bug with the cropbox in 2-up subcommand --- pdfly/up2.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pdfly/up2.py b/pdfly/up2.py index 93467284..a6a86deb 100644 --- a/pdfly/up2.py +++ b/pdfly/up2.py @@ -21,9 +21,14 @@ def main(pdf: Path, output: Path) -> None: lhs.merge_translated_page( rhs, tx=float(lhs.mediabox.width), ty=0, expand=True ) + # Lucas: expand=True triggers a mediabox size update in PageObject._expand_mediabox(), + # but sometimes the cropbox is also update in the process, sometimes it doesn't. + # I haven't investigated why, but maybe because those attributes are properties + # created with _create_rectangle_accessor(). + # Anyway, for now I prefer to ensure that the cropbox matches the mediabox: + lhs.cropbox = lhs.mediabox writer.add_page(lhs) sys.stdout.flush() - with open(output, "wb") as fp: writer.write(fp) print(f"{output} was created")