From: Christian Heller Date: Sun, 24 Sep 2023 23:36:24 +0000 (+0200) Subject: Bookmaker: Improve documentation. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7B%20web_path%20%7D%7D/%7B%7Bdb.prefix%7D%7D/do_todos?a=commitdiff_plain;h=0c5f2e3dd455f13a189b1cbd76ff8b78e2d0cf03;p=misc Bookmaker: Improve documentation. --- diff --git a/bookmaker.py b/bookmaker.py index 2dd9653..4b7faf4 100755 --- a/bookmaker.py +++ b/bookmaker.py @@ -1,9 +1,23 @@ #!/usr/bin/env python3 """ -bookmaker.py is a helper for optimizing PDFs of books 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. +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. """ help_epilogue = """ -EXAMPLES: +OVERVIEW OF TARGET USAGE: + +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: + + +-------=-------+ __________________ + (front) (back) | 4 | 1 = 2 | 3 | 4 /=|===|============ ++-------=-------+ ==> +-------=-------+ ===> _/|\_ v >=|===|============ +| 4 | 1 = 2 | 3 | / | \_ \=|===|============ +|-------=-------| +-------=-------+ 1-> | 2 | 3 | | \ / <- cut out! +| 8 | 5 = 6 | 7 | ==> | 8 | 5 = 6 | 7 | | _/ \_ | | \ | ++-------=-------+ +-------=-------+ |/ \| | \| (p. 5) + +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. + +COMMAND EXAMPLES: Concatenate two PDFs A.pdf and B.pdf to COMBINED.pdf: bookmaker.py --input_file A.pdf --input_file B.pdf --output_file COMBINED.pdf @@ -17,7 +31,7 @@ Produce COMBINED.pdf from A.pdf's first 7 pages, B.pdf's pages except its first Crop each page 5cm from the left, 10cm from the bottom, 2cm from the right, and 0cm from the top: bookmaker.py -i INPUT.pdf -o OUTPUT.pdf --crops "5,10,2,0" -Include all pages from INPUT.pdf, but crop pages 10-20 by 5cm each from bottom and top: +Include all pages from INPUT.pdf, but only crop pages 10-20 by 5cm each from bottom and top: bookmaker.py -i INPUT.pdf -c "10-20:0,5,0,5" -o OUTPUT.pdf Same crops for pages 10-20, but also crop all pages 30 and later by 3cm each from left and right: @@ -27,7 +41,7 @@ Rotate by 90° pages 3, 5, 7; rotate page 7 once more by 90% (i.e. 180° in tota bookmaker.py -i INPUT.pdf -o OUTPUT.pdf --rotate 3 -r 5 -r 7 -r 7 Initially declare 5cm crop from the left and 1cm crop from right, but alternate direction between even and odd pages: - bookmaker.py -i INPUT.pdf -o OUTPUT.pdf -c "5,0,1,0" -s + bookmaker.py -i INPUT.pdf -o OUTPUT.pdf -c "5,0,1,0" --symmetry Quarter each OUTPUT.pdf page to carry 4 pages from INPUT.pdf, draw stencils into inner margins for cuts to carry binding strings: bookmaker.py -i INPUT.pdf -o OUTPUT.pdf --nup4 @@ -35,29 +49,14 @@ Quarter each OUTPUT.pdf page to carry 4 pages from INPUT.pdf, draw stencils into 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: bookmaker.py -i INPUT.pdf -o OUTPUT.pdf -n --print_margin 1.3 -Same --nup4, but draw lines marking printable-region margins, page quarts, spine margins: +Same --nup4, but draw lines marking printable-region margins, page quarters, spine margins: bookmaker.py -i INPUT.pdf -o OUTPUT.pdf -n --analyze -NOTES: +FURTHER NOTES: For arguments like -p, page numbers are assumed to start with 1 (not 0, which is treated as an invalid page number value). 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). - -For --nup4, the -c cropping instructions do not so much erase content outside the cropped area, but rather zoom into the page in a way that maximes the cropped area as much as possible into the available per-page area between printable-area margins and the borders to the other quartered pages. If the zoomed cropped area does not fit in neatly into its per-page area, this will preserve additional page content. - -The --nup4 quartering puts pages into a specific order optimized for no-tumble duplex print-outs that can easily be folded and cut into pages of a small A6 book. Each unit of 8 pages from the source PDF is mapped thus onto two subsequent pages (i.e. front and back of a printed A4 paper): - - (front) (back) -+-------+ +-------+ -| 4 | 1 | | 2 | 3 | -|-------| |-------| -| 8 | 5 | | 6 | 7 | -+-------+ +-------+ - -To facilitate this layout, --nup4 also pads the input PDF pages to a total number that is a multiple of 8, by adding empty pages if necessary. - -(To turn above double-sided example page into a tiny 8-page book: Cut the paper in two on its horizontal middle line. Fold the two halves by their vertical middle lines, with pages 3-2 and 7-6 on the folds' insides. This creates two 4-page books of pages 1-4 and pages 5-8. Fold them both closed and (counter-intuitively) put the book of pages 5-8 on top of the other one (creating a temporary page order of 5,6,7,8,1,2,3,4). A binding cut stencil should be visible on the top left of this stack – cut it out (with all pages folded together) to add the same inner-margin upper cut to each page. Turn around your 8-pages stack to find the mirror image of aforementioned stencil on the stack's back's bottom, and cut that out too. Each page now has binding cuts on top and bottom of its inner margins. Swap the order of both books (back to the final page order of 1,2,3,4,5,6,7,8), and you now have an 8-pages book that can be "bound" in its binding cuts through a rubber band or the like. Repeat with the next 8-pages double-page, et cetera. (Actually, with just 8 pages, the paper may curl under the pressure of a rubber band – but go up to 32 pages or so, and the result will become quite stable.) """ import argparse import io