booklet.sh for PDF imposition into a booklet[edit]

I found another way to do imposition using a script Michael wrote called booklet.sh, downloadable here: https://git.xpub.nl/murtaugh/95layouts
It's a shell script that can run in the bin folder from the home directory, which allows you to run it wherever you are in the computer - you don't have to cd to the folder where the script is. To enable this, first you have to echo the path for the bin folder that the scripts are in. The command to run it from the terminal is:

booklet.sh source.pdf

It needs a few dependencies to run (mainly psutils).

  1. Requirements: psutils, pdftk, python3 with reportlab (make_blank_pdf.py)
input=$1
base=${input%.*}
echo converting $input to $base.booklet.pdf
pdftk_utils.py $input pad --multiple 4 --output $base.01.pdf
pdftops -paper match $base.01.pdf $base.01.ps
psbook -s`pdftk_utils.py $base.01.pdf count` $base.01.ps $base.02.ps
psnup -2 -PA4 $base.02.ps $base.03.ps
ps2pdf $base.03.ps $base.booklet.pdf
rm $base.01.pdf $base.01.ps $base.02.ps $base.03.ps

Note: Comment out or delete the last line to produce three .ps files - the first one is the source PDF, the second is the PDF imposed in the correct order, the third one is the imposed PDF pages on an A4 page. This works well if all you want to do is impose, print and fold. For cutting sheets you need to position the pages 2-up, centred on the page, which I can't quite figure out how to do...