home · contact · privacy
In DIY book maker, fix horizontal shifts.
authorChristian Heller <c.heller@plomlompom.de>
Wed, 20 Sep 2023 21:27:39 +0000 (23:27 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 20 Sep 2023 21:27:39 +0000 (23:27 +0200)
bookmaker.py

index e6c8d2aa7a0375452bcd305973f43e9e30ad408f..0e35820654fb55677c7f341d6db1f3905871cea4 100755 (executable)
@@ -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))