Extracts a given set of pages from a pdf and rearranges them in an order useful for printing in a book format. Pages can be arranged for easy folding of a 2-up layout to make booklets. Pages can be arranged for cutting the 2-up layout in the middle and placing one half on top of the other without the need for hand collating. Print the front side or the back side independently, for printers that can't print on both sides of the paper. The back side can be printed in reverse order if needed.
pdfTonto - Arrange pages of a PDF for easier printing of books
pdfTonto [options] [< input.pdf] [> out.pdf]
Required Options (at least one is required):
--pages page-list : List of pages to extract
--filter name : Arrangement filter to use
--in filename : Get input from filename instead of standard in
--out filename : Write to filename instead of standard out
--sig N : Signature size. Only used by some filters
--help, -? : Display more help info
--man : Display full man page
Extracts a given set of pages from a pdf and rearranges them in an order useful for printing in a book format.
Pages can be arranged for easy folding of a 2-up layout to make booklets.
Pages can be arranged for cutting the 2-up layout in the middle and placing one half on top of the other without the need for hand collating.
Print the front side or the back side independently, for printers that can't print on both sides of the paper. The back side can be printed in reverse order if needed.
--pages page-list, -p page-list
The list of pages to extract from the input PDF. Use commas to separate pages or ranges and use a dash to specify a range (i.e. 1,3,6-12). Pages can be put in any order and can even be repeated (i.e. 15,30,17,7,17,0). Use page number zero to put a blank page in that position. If the --pages option is not used, then all pages in the input PDF will be passed to the --filter. Either one or both of --filter and --pages must be used.
--filter name, -f name
The filter to use on the extracted pages to rearrange them for printing. See the man page for a list of existing filters and their explanations. If the --filter option is not used, then pages are written to the output PDF in the exact order given in the --pages option. Either one or both of --filter and --pages must be used.
--in filename, -i filename
The PDF file to use as the source. Defaults to the standard input if not specified.
--out filename, -o filename
The PDF file to write the results to. Defaults to the standard output if not specified. Will overwrite the file if it exists.
Specify the number N of sheets that make up a signature (sub-book let) for filters that support them. Defaults to no signatures. Signatures is a technique useful for binding books larger than a few dozen pages.
--help, -?, --man
View the help text
For 2-up layout printing. Arranges pages so that the sheets can be folded and proper page order is maintained. Supports the --sig option. For booklets of more than a few dozen pages, signatures are recommended.
Same as booklet, but only outputs pages for the front side of each sheet. Use for 2-up printing on printers that only print on one side of the paper.
Same as booklet, but only outputs pages for the back side of each sheet. Use for 2-up printing on printers that only print on one side of the paper. Depending on how the printer outputs sheets, booklet_back_reverse may be needed instead.
Same as booklet_back, but prints in reverse sheet order.
For 2-up layout printing. Arranges pages so that the entire stack can be sliced in half, the left stack can be placed on top of the right stack, and all the pages will be in order. If the printer does not support printing on both sides of the paper, use the front, back, and back_reverse variants.
For 4-up layout printing. Useful if the target printer doesn't duplex (print on both sides). First use 4up_front to print, then turn the stack over and feed it through again using either 4up_back or 4up_back_reverse (depending on how the printer outputs the paper).
Capturing a range of pages from a larger PDF and sending them as a booklet directly to a printer using CUPS. The printer supports 2-up layout and printing on both sides:
pdfTonto -i in.pdf -p 34-86 -f booklet | \ lp -d printer-name -o sides=two-sided-short-edge -o number-up=2
Using the same range of pages in booklet form, but sending them to a printer that can only handle single sided printing. This will require two passes of the paper through the printer:
pdfTonto -i in.pdf -p 34-86 -f booklet_front | \ lp -d printer-name -o number-up=2 pdfTonto -i in.pdf -p 34-86 -f booklet_back | \ lp -d printer-name -o number-up=2
Save the page range in slicestack form so you can take the PDF to work and print it on a high quality duplex printer, use the large vertical paper cutter to trim the pages, and use the plastic-comb binding machine to put them all together in a nice book. What? Don't you have those where you work?
pdfTonto -i in.pdf -p 34-86 -f slicestack -o out.pdf
pdfTonto does not actually resize, rotate, and combine multiple input pages onto a single output page. It only reorders the pages so that they'll come out of the printer correctly for binding into a book. Your printer and driver still need to print in 2-up or 4-up mode. If your printer does not support N-up printing, then you have bigger problems than reordering the pages of a PDF.
pdfTonto takes advantage of the "Incremental Update" feature of Adobe's PDF Specification. It only writes the new page directory to the end of the file. This is a much faster method than rewriting the entire PDF from scratch. This also means that the output PDF file will not reduce in size, even if you are sampling 10 pages out of a 1200 page PDF.
If you need to have a smaller file (so it will fit on a flash drive, for example), open the output PDF in a viewing program, such as Preview in Mac OS X, and use "Save As..." to create a new copy. The program will rewrite the PDF from scratch, omitting any data not referenced by the page directory created by pdfTonto.
This script will not read PDF's containing Cross Reference Streams added at version 1.5 of Adobe's PDF Specification. If there is enough demand for it, I may look into adding that additional feature.
For the few PDF's I've come across using Object Streams, I simply opened them in a viewing application (Mac OS X Preview) and chose "Save as...", which rewrote the PDF in a format without the compressed streams. I then used pdfTonto on that second PDF with no troubles.
pdfTonto will not work with encrypted PDF files.
A Tonto is a type of Japanese knife or dagger. Tonto also means "idiot" in Spanish. Either one of these could explain the name "pdfTonto". However, I originally wanted to call this "pdfArranger", but that was too close to a couple of other programs out there. So, the thought process went like this:
pdfArranger...A Ranger...Lone Ranger...Tonto...pdfTonto
Now you'll never forget it, Kemo Sabe :-)