Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My father-in-law usually creates his newsletters pre-'booked' -- that is, two columns with the pages in the right place such that you can print and staple the newsletter. Unfortunately, this month we're using a printer that wants an un-booked PDF -- with one page per page, in the right order. I can re-order pages easily enough, but is there any way to take a PDF which is essentially 2-up and split the pages?

share|improve this question
    
What application did you use to generate the pdf? InDesign? It's in the app you used that you'd specify the print configuration (2-up for booklet, newsletter, etc.). Just change the print config to single page output and regenerate the pdf. –  burrowsrjl Nov 15 '12 at 20:14
    
@burrowsrjl The booklet was generated using LibreOffice, but by putting two columns on each page so it folds nicely without setting any print config -- not my set-up :). –  Andrew Aylett Nov 16 '12 at 15:44

1 Answer 1

for both raster and vector pdf content you can use this my script I named decutshuffler

usage:

decutshuffler filename.pdf

#!/bin/bash
#a script that takes a 2-up booklet, cut in half the two halves, mix together one by one the pages from odd and even resulting pdf and finally reorder pages in sequential order
filename=$1
w="$(pdfinfo $filename | grep "Page size" | cut -d x -f1 | tr 'Page size:' ' ' | xargs)"
h="$(pdfinfo $filename | grep "Page size" | cut -d x -f2  | tr 'pts' ' ' | xargs)"
halfw="`echo "scale=0; $w / 2" | bc -l`"
pages="`pdftk $filename dump_data output |grep Pages|cut -f2 -d :`"
sed -e "s/$w $h/$halfw $h/g"<$filename>even.pdf
sed -e "s/0 0 $w $h/$w 0 $halfw $h/g"<$filename>odd.pdf
rule="$(for i in `seq 1 $pages`; do echo -n "A$i B$i "; done)"
pdftk A=even.pdf B=odd.pdf cat $rule output interleaved.pdf
doubled="`echo "scale=0; $pages * 2" | bc -l`"
pages4="`echo "scale=0; $doubled / 2" | bc -l`"
deshuf="$(for ((x=$doubled, y=1;x>=$pages4, y<=$pages4;x--, y++)); do echo "$x $y "; done |awk '{ print ; getline ; print $2, $1 }' | tr ' ' '\n' | cat -b | sort -n +1 -2| cut -f1 | tr '\n' ' '| xargs)"
pdftk interleaved.pdf cat $deshuf output deshuffled.pdf
pdftk deshuffled.pdf output fixed.pdf && mv fixed.pdf deshuffled.pdf
echo "file created!"

echo $pages
echo $deshuf
echo "halfw is $halfw"

exit 0

this script

  1. takes your pdf imposed as 2-up booklet as input

  2. split the source pdf into its two halves producing a file with odd pages and a file with even pages

  3. mix odd.pdf and even.pdf together into one file, taking, alternately, page 1 from odd, page 1 from even, page 2 from odd, page 2 from even... and so on...

  4. finally, it with a special rule, reorders the file into sequential order, so pages, instead to be (for a 16 pages long booklet)

16 1 2 15 14 3 4 13 12 5 6 11 10 7 8 9

are disposed sequentially in its natural order:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.