From: Christian Heller Date: Sun, 24 Sep 2023 00:16:17 +0000 (+0200) Subject: Bookmaker: Remove unnecessary --spine option, use -s for --symmetry. X-Git-Url: https://plomlompom.com/repos/%22https:/validator.w3.org/%7B%7Bprefix%7D%7D/%7B%7Btodo.comment%7D%7D?a=commitdiff_plain;h=84b45203eace6e54962a2695f89a4193c644226d;p=misc Bookmaker: Remove unnecessary --spine option, use -s for --symmetry. --- diff --git a/bookmaker.py b/bookmaker.py index b9daa0b..3737edc 100755 --- a/bookmaker.py +++ b/bookmaker.py @@ -8,18 +8,18 @@ points_per_cm = 10 * 72 / 25.4 cut_depth = 1.95 * points_per_cm cut_width = 1.05 * points_per_cm middle_point_depth = 0.4 * points_per_cm +spine_limit = 1 * points_per_cm parser = argparse.ArgumentParser(description="build print-ready book PDF") parser.add_argument("-i", "--input_file", action="append", required=True, help="input PDF file") parser.add_argument("-o", "--output_file", required=True, help="output PDF file") parser.add_argument("-p", "--page_range", action="append", help="page range, e.g., '3-end'") parser.add_argument("-c", "--crop_range", action="append", help="cm crops left, bottom, right, top – e.g., '10,10,10,10'; prefix with ':'-delimited page range to limit effect") -parser.add_argument("-t", "--symmetry", action="store_true", help="alternate horizontal crops between odd and even pages") +parser.add_argument("-s", "--symmetry", action="store_true", help="alternate horizontal crops between odd and even pages") 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("-n", "--nup4", action='store_true', help="puts 4 input pages onto 1 output page") parser.add_argument("-a", "--analyze", action="store_true", help="in --nup4, print lines identifying spine, page borders") parser.add_argument("-m", "--margin", type=float, default=0.43, help="print margin for --nup4 in cm (default 0.43)") -parser.add_argument("-s", "--spine", type=float, default=1, help="on --nup4, cm width of margin hidden in spine (default 1)") args = parser.parse_args() @@ -70,7 +70,7 @@ for page in pages_to_add: page.mediabox.right = a4_width page.cropbox = page.mediabox -# determine page crops, zooms +# determine page crops, zooms, crop symmetry crops_at_page = [(0,0,0,0)]*len(pages_to_add) zoom_at_page = [1]*len(pages_to_add) if args.crop_range: @@ -109,6 +109,8 @@ if args.crop_range: writer = pypdf.PdfWriter() if not args.nup4: + # single-page output + print("building 1-input-page-per-output-page book") odd_page = True for i, page in enumerate(pages_to_add): crop_left, crop_bottom, crop_right, crop_top = crops_at_page[i] @@ -123,8 +125,8 @@ if not args.nup4: odd_page = not odd_page else: + print("-n: building 4-input-pages-per-output-page book") n_pages_per_axis = 2 - spine_limit = args.spine * points_per_cm printable_margin = args.margin * points_per_cm printable_scale = (a4_width - 2*printable_margin)/a4_width half_width = a4_width / n_pages_per_axis