1 usage: bookmaker.py [-h] -i INPUT_FILE -o OUTPUT_FILE [-p PAGE_RANGE]
2 [-c CROPS] [-r ROTATE_PAGE] [-s] [-n] [-a]
5 bookmaker.py is a helper for optimizing PDFs for the production of small self-printed, self-bound physical books. Towards this goal it offers various PDF manipulation options that may also be used indepéndently and for other purposes.
8 -h, --help show this help message and exit
9 -i INPUT_FILE, --input_file INPUT_FILE
11 -o OUTPUT_FILE, --output_file OUTPUT_FILE
13 -p PAGE_RANGE, --page_range PAGE_RANGE
14 page range, e.g., '2-9' or '3-end' or 'start-14'
15 -c CROPS, --crops CROPS
16 cm crops left, bottom, right, top – e.g.,
17 '10,10,10,10'; prefix with ':'-delimited page range to
19 -r ROTATE_PAGE, --rotate_page ROTATE_PAGE
20 rotate page of number by 90° (usable multiple times on
22 -s, --symmetry alternate horizontal crops between odd and even pages
23 -n, --nup4 puts 4 input pages onto 1 output page, adds binding
25 -a, --analyze in --nup4, print lines identifying spine, page borders
26 -m PRINT_MARGIN, --print_margin PRINT_MARGIN
27 print margin for --nup4 in cm (default 0.43)
29 OVERVIEW OF TARGET USAGE:
31 By cropping with -c and studying the results, define the areas of the input PDF's pages you want visible. Then, with--nup4, map those areas onto 4 input pages per 1 output page, arranged in such a way that double-sided print-out of those output pages can be cut, folded, and bound (helped by addition of stencils for small incisions to carry rubber bands or the like) into a small A6 book. Each unit of 8 pages from the input PDF is mapped by --nup4 onto two pages representing two sides of a (no-tumble-duplex-printed) A4 paper:
33 +-------=-------+ __________________
34 (front) (back) | 4 | 1 = 2 | 3 | 4 /=|===|============
35 +-------=-------+ ==> +-------=-------+ ===> _/|\_ v >=|===|============
36 | 4 | 1 = 2 | 3 | / | \_ \=|===|============
37 |-------=-------| +-------=-------+ 1-> | 2 | 3 | | \ / <- cut out!
38 | 8 | 5 = 6 | 7 | ==> | 8 | 5 = 6 | 7 | | _/ \_ | | \ |
39 +-------=-------+ +-------=-------+ |/ \| | \| (p. 5)
41 To turn this paper into a small 8-pages book, first cut it into two A5 papers along its horizontal middle. Fold both A5's by their vertical middles, with pages 2-3 and 7-6 on the folds' insides. You now have two 4-page A6 "books" of pages 1-4 and pages 5-8. Fold both closed and (counter-intuitively) stack the second one on top of the first one (creating a temporary page order of 5,6,7,8,1,2,3,4). This reveals a small stencil on the top left of page 5 – cut it out, with all other pages folded and aligned under it, creating a small notch in the upper "inner" corner of all pages. Turn around the stack to find a mirror stencil on the bottom and repeat the cutting. Each page now has cuts on top and bottom of its inner margins into which a rubber band can be hooked, or through which a string may be looped and tied, to bind the page's inner margins into a kind of book spine. You may now swap the order of the 4-page books back into a proper final page order (of 1,2,3,4,5,6,7,8) and repeat the whole process for each further --nup4 output paper.
45 Concatenate two PDFs A.pdf and B.pdf to COMBINED.pdf:
46 bookmaker.py --input_file A.pdf --input_file B.pdf --output_file COMBINED.pdf
48 Produce OUTPUT.pdf containing all pages of (inclusive) page number range 3-7 from INPUT.pdf:
49 bookmaker.py -i INPUT.pdf --page_range 3-7 -o OUTPUT.pdf
51 Produce COMBINED.pdf from A.pdf's first 7 pages, B.pdf's pages except its first two, and all pages of C.pdf:
52 bookmaker.py -i A.pdf -p start-7 -i B.pdf -p 3-end -i C.pdf -o COMBINED.pdf
54 Crop each page 5cm from the left, 10cm from the bottom, 2cm from the right, and 0cm from the top:
55 bookmaker.py -i INPUT.pdf -o OUTPUT.pdf --crops "5,10,2,0"
57 Include all pages from INPUT.pdf, but only crop pages 10-20 by 5cm each from bottom and top:
58 bookmaker.py -i INPUT.pdf -c "10-20:0,5,0,5" -o OUTPUT.pdf
60 Same crops for pages 10-20, but also crop all pages 30 and later by 3cm each from left and right:
61 bookmaker.py -i INPUT.pdf -o OUTPUT.pdf -c "10-20:0,5,0,5" -c "30-end:3,0,3,0"
63 Rotate by 90° pages 3, 5, 7; rotate page 7 once more by 90% (i.e. 180° in total):
64 bookmaker.py -i INPUT.pdf -o OUTPUT.pdf --rotate 3 -r 5 -r 7 -r 7
66 Initially declare 5cm crop from the left and 1cm crop from right, but alternate direction between even and odd pages:
67 bookmaker.py -i INPUT.pdf -o OUTPUT.pdf -c "5,0,1,0" --symmetry
69 Quarter each OUTPUT.pdf page to carry 4 pages from INPUT.pdf, draw stencils into inner margins for cuts to carry binding strings:
70 bookmaker.py -i INPUT.pdf -o OUTPUT.pdf --nup4
72 Same --nup4, but define a printable-region margin of 1.3cm to limit the space for the INPUT.pdf pages in OUTPUT.pdf page quarters:
73 bookmaker.py -i INPUT.pdf -o OUTPUT.pdf -n --print_margin 1.3
75 Same --nup4, but draw lines marking printable-region margins, page quarters, spine margins:
76 bookmaker.py -i INPUT.pdf -o OUTPUT.pdf -n --analyze
80 For arguments like -p, page numbers are assumed to start with 1 (not 0, which is treated as an invalid page number value).
82 The target page shape so far is assumed to be A4 in portrait orientation; bookmaker.py normalizes all pages to this format before applying crops, and removes any source PDF /Rotate commands (for their production of landscape orientations).