From: Christian Heller Date: Sat, 23 Sep 2023 22:23:25 +0000 (+0200) Subject: In Bookmaker script, allow multiple rotation arguments. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/new_day?a=commitdiff_plain;h=792204427264001fc02a9fcdc88d3e8c19f3f0b5;p=misc In Bookmaker script, allow multiple rotation arguments. --- 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: