mybin

my ~/bin
git clone https://a3nm.net/git/mybin/
Log | Files | Refs | README

pdfpagecat (411B)


      1 #!/bin/bash
      2 
      3 # concatenate PDF files, introducing blank pages when necessary, for duplex
      4 # printing
      5 
      6 nargs=()
      7 
      8 if [ -t 1 ] ; then
      9   echo "stdout should be the output file, not a terminal"
     10   exit 1
     11 fi
     12 
     13 for f in "$@"
     14 do
     15   nargs+=("$f")
     16   NP=$(pdfinfo "$f" | grep '^Pages:' | awk '{print $2}')
     17   if [ $((NP % 2)) -eq 1 ]
     18   then
     19     nargs+=($HOME/git/misc/blank_a4.pdf)
     20   fi
     21 done
     22 
     23 pdftk "${nargs[@]}" cat output -
     24