From 792204427264001fc02a9fcdc88d3e8c19f3f0b5 Mon Sep 17 00:00:00 2001 From: Christian Heller <c.heller@plomlompom.de> Date: Sun, 24 Sep 2023 00:23:25 +0200 Subject: [PATCH] In Bookmaker script, allow multiple rotation arguments. --- bookmaker.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bookmaker.py b/bookmaker.py index eb6fd11..ca3548b 100755 --- a/bookmaker.py +++ b/bookmaker.py @@ -13,7 +13,7 @@ parser.add_argument("-c", "--crop", dest="crop_range", help="crops left, bottom, parser.add_argument("-n", "--nup4", dest="nup4", action='store_true', help="puts 4 input pages onto 1 output page") parser.add_argument("-a", "--analyze", dest="analyze", action="store_true", help="print lines identifying spine, page borders") parser.add_argument("-t", "--symmetry", dest="symmetry", action="store_true", help="alternate horizontal crops between odd and even pages") -parser.add_argument("-r", "--rotate", dest="rotate", help="rotate page of number by 90°") +parser.add_argument("-r", "--rotate", dest="rotate", type=int, action="append", help="rotate page of number by 90° (usable multiple times on same page!)") parser.add_argument("-m", "--margin", type=float, default=4.3, help="print margin (default 4.3)") args = parser.parse_args() @@ -40,10 +40,11 @@ for i, input_file in enumerate(args.input_file): # rotate page canvas if args.rotate: - page = pages_to_add[int(args.rotate) - 1] - page.add_transformation(pypdf.Transformation().translate(tx=-a4_width/2, ty=-a4_height/2)) - page.add_transformation(pypdf.Transformation().rotate(-90)) - page.add_transformation(pypdf.Transformation().translate(tx=a4_width/2, ty=a4_height/2)) + for rotate in args.rotate: + page = pages_to_add[rotate - 1] + page.add_transformation(pypdf.Transformation().translate(tx=-a4_width/2, ty=-a4_height/2)) + page.add_transformation(pypdf.Transformation().rotate(-90)) + page.add_transformation(pypdf.Transformation().translate(tx=a4_width/2, ty=a4_height/2)) # normalize all pages to portrait A4 for page in pages_to_add: -- 2.30.2