Monday, October 26, 2015

Making booklets

Our newspaper kids wanted to make a mini-booklet-style 5.5x4.25" newspaper made of simple 8.5x11" sheets of paper folded.

To do the layout properly with nice 2-page spreads etc., we set the papersize in our software to 5.5"x4.25", but that then raises the problem of how to properly print it out on copy paper so it folds neatly.

After much searching, I found a useful post which has just the instructions I needed -- here is a shellscript to implement the solution with my own variants:

echo Converting to postscript
pdf2ps $1 working_file.ps
echo Rotating pages
pstops -w 4.25in -h 5.5in 8:7\(0.0in,0.01in\),0\(0.0in,0.01in\),4U\(4.25in,5.50in\),3U\(4.25in,5.50in\),1\(0.0in,0.01in\),6\(0.0in,0.01in\),2U\(4.25in,5.50in\),5U\(4.25in,5.50in\) working_file.ps working_ordered.ps
echo Putting 4 to a page
psnup -4 -s1 working_ordered.ps output.ps
echo Outputting to PDF
filename=$1
filename="${filename%.*}"
ps2pdf output.ps $filename.bookematized.pdf
echo "Done. Output in: $filename.bookematized.pdf"

The magic is in that pstops line with the page order and the flipping of the appropriate pages. The psnup line just slaps four pages onto a page, which is simple enough.

Since my pages were appropriately formatted, I used the -s1 command to prevent psnup from scaling. If you wanted to take e.g. 4 8.5x11 pages and shrink them to fit on 4.25x5.5, you could do it by adjusting the paper sizes in the pstops line and then removing the -s1 line (that's what the original code I copied does, more or less -- so just start there).