From: Christian Heller Date: Sun, 24 Sep 2023 04:34:21 +0000 (+0200) Subject: Bookmaker: Improve documentation. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/static/day?a=commitdiff_plain;h=7de2916603e5b9761142cd51e385d956ad88285a;p=misc Bookmaker: Improve documentation. --- diff --git a/bookmaker.py b/bookmaker.py index d23c20d..0645378 100755 --- a/bookmaker.py +++ b/bookmaker.py @@ -34,7 +34,7 @@ Concatenate two PDFs A.pdf and B.pdf to COMBINED.pdf: Produce OUTPUT.pdf containing all pages of (inclusive) page number range 3-7 from INPUT.pdf: bookmaker.py -i INPUT.pdf --page_range 3-7 -o OUTPUT.pdf -Produce COMBINED-pdf from A.pdf's first 7 pages, B.pdf's pages except its first two, and all pages of C.pdf: +Produce COMBINED.pdf from A.pdf's first 7 pages, B.pdf's pages except its first two, and all pages of C.pdf: bookmaker.py -i A.pdf -p start-7 -i B.pdf -p 3-end -i C.pdf -o COMBINED.pdf Crop each page 5cm from the left, 10cm from the bottom, 2cm from the right, and 0cm from the top: @@ -43,7 +43,7 @@ Crop each page 5cm from the left, 10cm from the bottom, 2cm from the right, and Include all pages from INPUT.pdf, but 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 from on pages 10-20, but also crop all pages 30 and later by 3cm each from left and right: +Same crops for pages 10-20, but also crop all pages 30 and later by 3cm each from left and right: bookmaker.py -i INPUT.pdf -o OUTPUT.pdf -c "10-20:0,5,0,5" -c "30-end:3,0,3,0" Rotate by 90° pages 3, 5, 7; rotate page 7 once more by 90% (i.e. 180° in total): @@ -67,6 +67,8 @@ For arguments like -p, page numbers are assumed to start with 1 (not 0, which is 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) @@ -76,9 +78,9 @@ The --nup4 quartering puts pages into a specific order optimized for no-tumble d | 8 | 5 | | 7 | 6 | +-------+ +-------+ -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. +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 this 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 it 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.) +(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.) """ # some helpers @@ -135,7 +137,6 @@ def parse_page_range(range_string, pages): def parse_args(): parser = argparse.ArgumentParser(description=__doc__, epilog=help_epilogue, formatter_class=argparse.RawDescriptionHelpFormatter) - parser._optionals.title = "OPTIONS" 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., '2-9' or '3-end' or 'start-14'")