From 6ab7b2a87311169b7841b04e4f0356de04774ef9 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Thu, 25 May 2023 20:53:17 +0200 Subject: Print two signatures on 4 A4 pages --- a6_book.py | 32 +- templates/piecepack/minipack-grid.svg | 3993 +++++++++++++++++++++++++++++++++ 2 files changed, 4021 insertions(+), 4 deletions(-) create mode 100644 templates/piecepack/minipack-grid.svg diff --git a/a6_book.py b/a6_book.py index 189018f..2a641ba 100755 --- a/a6_book.py +++ b/a6_book.py @@ -12,6 +12,17 @@ SIGNATURE = ( 5, 10, 7, 8, ) +SIGNATURE_32 = ( + 15, 0, 31, 16, + 1, 14, 17, 30, + 13, 2, 29, 18, + 3, 12, 19, 28, + 11, 3, 27, 20, + 5, 10, 21, 26, + 9, 6, 25, 22, + 7, 8, 23, 24, +) + def get_parser(): parser = argparse.ArgumentParser() @@ -19,6 +30,12 @@ def get_parser(): "--file", '-f', help="Name of the PDF file", ) + parser.add_argument( + "--double", "-d", + action="store_true", + help="Put two signatures on 4 A4 sheet. Pages should be a " + "multiple of 32", + ) parser.add_argument( "pagespec", help="Page selection. At the moment only '-' is supported" @@ -38,16 +55,23 @@ def main(): except IndexError: parser.print_usage() + if args.double: + signature = SIGNATURE_32 + else: + signature = SIGNATURE + sig_len = len(signature) + pages = [str(i) for i in range(start, end+1)] - if len(pages) % 16 != 0: - empty = 16 - len(pages) % 16 + if len(pages) % sig_len != 0: + empty = sig_len - len(pages) % sig_len pages = pages + ["{}"] * empty rearranged = [] + while pages: - for i in SIGNATURE: + for i in signature: rearranged.append(pages[i]) - pages = pages[16:] + pages = pages[sig_len:] base, ext = os.path.splitext(args.file) out_fname = base + '-book' + ext diff --git a/templates/piecepack/minipack-grid.svg b/templates/piecepack/minipack-grid.svg new file mode 100644 index 0000000..217d70b --- /dev/null +++ b/templates/piecepack/minipack-grid.svg @@ -0,0 +1,3993 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + 2 + + + + 2 + + + + 2 + + + + 3 + + + + 3 + + + + 3 + + + + 3 + + + + 4 + + + + 4 + + + + 4 + + + + 4 + + + + 5 + + + + 5 + + + + 5 + + + + 5 + + + + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + + + + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3