summaryrefslogtreecommitdiff
path: root/a6_book.py
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2023-05-25 20:53:17 +0200
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2023-05-25 20:54:23 +0200
commit6ab7b2a87311169b7841b04e4f0356de04774ef9 (patch)
treeebad6c8733da87044ecadbdae29f4f947b15e28a /a6_book.py
parent3bccb1539f74513cee0aa831d81da8cec92aae1b (diff)
Print two signatures on 4 A4 pages
Diffstat (limited to 'a6_book.py')
-rwxr-xr-xa6_book.py32
1 files changed, 28 insertions, 4 deletions
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()
@@ -20,6 +31,12 @@ def get_parser():
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 '<start>-<end>' 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