From 266b44bd6522bd9c16c7f581648fe28c9b172b64 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Wed, 20 Sep 2023 23:27:39 +0200 Subject: [PATCH] In DIY book maker, fix horizontal shifts. --- bookmaker.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bookmaker.py b/bookmaker.py index e6c8d2a..0e35820 100755 --- a/bookmaker.py +++ b/bookmaker.py @@ -85,9 +85,9 @@ with open(args.input_file, 'rb') as file: odd_page = True for page in pages_to_add: if args.symmetry and odd_page: - page.add_transformation(pypdf.Transformation().translate(tx=-crop_left, ty=-crop_bottom)) - else: page.add_transformation(pypdf.Transformation().translate(tx=-crop_right, ty=-crop_bottom)) + else: + page.add_transformation(pypdf.Transformation().translate(tx=-crop_left, ty=-crop_bottom)) page.add_transformation(pypdf.Transformation().scale(zoom, zoom)) page.mediabox.right = cropped_width * zoom page.mediabox.top = cropped_height * zoom @@ -138,11 +138,14 @@ with open(args.input_file, 'rb') as file: page.add_transformation(pypdf.Transformation().translate(ty=(a4_height / zoom - (a4_height - crop_top)))) if i == 0 or i == 2: if args.symmetry: - page.add_transformation(pypdf.Transformation().translate(tx=-crop_right)) - else: page.add_transformation(pypdf.Transformation().translate(tx=-crop_left)) + else: + page.add_transformation(pypdf.Transformation().translate(tx=-crop_right)) elif i == 1 or i == 3: - page.add_transformation(pypdf.Transformation().translate(tx=(a4_width / zoom - (a4_width - crop_right)))) + if args.symmetry: + page.add_transformation(pypdf.Transformation().translate(tx=(a4_width / zoom - (a4_width - crop_left)))) + else: + page.add_transformation(pypdf.Transformation().translate(tx=(a4_width / zoom - (a4_width - crop_right)))) page.add_transformation(pypdf.Transformation().scale(zoom * bonus_shrink_factor, zoom * bonus_shrink_factor)) if i == 2 or i == 3: page.add_transformation(pypdf.Transformation().translate(ty=-2*printable_margin/printable_scale)) -- 2.30.2