#!/usr/bin/bash# Create printable booklet from a scanned book pdf## Here we want to print an A5 size booklet in a way that on the top side of# each A4 page we print two consecutive odd pages (e.g. 1 and 3), while on# the other side the two corresponding even pages (4 and 2). Then we send# the document to the printer with 2 pages per page and two sided printing# (flip on short edge) settings. The printed A4 pages can be cut precisely# in the middle into A5 size with a paper cutting tool. Finally, we bind# the A5 pages together to form a booklet.## To create a pdf with a page order suitable for this kind of printing, we# use pdftk (PDF Toolkit), a simple and efficient command line tool for pdf# manipulation. The tool is available from the web page below or from most# of the Linux package repositories.## https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/## Once we have pdftk installed, it takes only two commands to reorder the# pages. First we sort the even and odd pages into separate files. Then we# merge these files in a way that we take 2 pages from the odd pages, and# 2 from the even but in reversed order.pdftk original.pdf cat 1-endeven output even.pdf
pdftk original.pdf cat 1-endodd output odd.pdf
pdftk A=odd.pdf B=even.pdf shuffle Aodd Aeven Beven Bodd output booklet.pdf
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.