From: Christian Heller Date: Wed, 20 Sep 2023 21:27:39 +0000 (+0200) Subject: In DIY book maker, fix horizontal shifts. X-Git-Url: https://plomlompom.com/repos/%22https:/validator.w3.org/%7B%7Bdb.prefix%7D%7D/%7B%7Btodo.comment%7D%7D?a=commitdiff_plain;h=266b44bd6522bd9c16c7f581648fe28c9b172b64;p=misc In DIY book maker, fix horizontal shifts. --- 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))