Hex, Bugs and More Physics | Emre S. Tasci

a blog about physics, computation, computational physics and materials…

Creating Booklets from PDF files

May 29, 2008 Posted by Emre S. Tasci

Some printers have the ability to automatically generate booklets from the sequentially ordered pdf files you send to them. But some (95%) don’t and if your printer is indeed one of the majority, you can definitely benefit from this script which converts your pdf files into booklets. The pages are shrunk to A5 and all you need in order to have your booklet is just to fold the output from the middle. I found this script via Maemst Blog who points at the PDF/PS hacks page of Pro-Linux page and also to Michael Roessler‘s script which I’m quoting as follows:

sururi@dutsm0175 tmp $ cat booklet.sh
#!/bin/bash
#
# call with file.pdf
file=$1
filebase=$(basename $file .pdf)
pdftops $file output.ps
psbook output.ps tmp.ps
pstops "4:0L@.7(21cm,0)+1L@.7(21cm,14.85cm),2R@.7(0,29.7cm)+3R@.7(0,14.85cm)" tmp.ps > ${filebase}-booklet.ps
rm -f output.ps tmp.ps
echo "Converting back to pdf …"
ps2pdf ${filebase}-booklet.ps
rm -f ${filebase}-booklet.ps
sururi@dutsm0175 tmp $

There may be some problems when your path includes spaces (even if you escape them) and the first page may be in the wrong side (and inverted) but these are really minor annoyances compared to what this script achieves.

Usage is pretty simple:

booklet.sh <input_file_name.pdf>

and the output file will be input_file_name-booklet.pdf

 

Btw, this will be the first post under the new category Tools.

Leave a Reply