Skip to content

Commit c15e907

Browse files
authored
BUG: Fix a bug with the cropbox in 2-up subcommand (#154)
1 parent ba73d7c commit c15e907

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

pdfly/up2.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@ def main(pdf: Path, output: Path) -> None:
2121
lhs.merge_translated_page(
2222
rhs, tx=float(lhs.mediabox.width), ty=0, expand=True
2323
)
24+
# Lucas: expand=True triggers a mediabox size update in PageObject._expand_mediabox(),
25+
# but sometimes the cropbox is also update in the process, sometimes it doesn't.
26+
# I haven't investigated why, but maybe because those attributes are properties
27+
# created with _create_rectangle_accessor().
28+
# Anyway, for now I prefer to ensure that the cropbox matches the mediabox:
29+
lhs.cropbox = lhs.mediabox
2430
writer.add_page(lhs)
2531
sys.stdout.flush()
26-
2732
with open(output, "wb") as fp:
2833
writer.write(fp)
2934
print(f"{output} was created")

0 commit comments

Comments
 (0)