Skip to content

Instantly share code, notes, and snippets.

@jhamfler
Last active June 11, 2020 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhamfler/fb750cc3a8ce4e757145bc078aa46483 to your computer and use it in GitHub Desktop.
Save jhamfler/fb750cc3a8ce4e757145bc078aa46483 to your computer and use it in GitHub Desktop.
PDF commands
# split all A3 pages into A4 except first and last
a=($(ls -d *.pdf))
for f in ${a[@]} ;do
[ "${a[1]} " != "$f " ] && [ "${a[-1]} " != "$f " ] && pdfposter -m a4 -p 2x1a4 "$f" "$f.cut"
done
# rotate +90° (mathematical) and split all pages
b=($(ls -d *.cut))
for f in ${b[@]} ;do
pdftk $f cat 1-endwest output "$f.pdf"
done
# concatenate all well oriented pages
pdftk "${a[1]}" *.cut.pdf "${a[-1]}" cat output 1.pdf
##################################
# do all this without the last pdf
a=($(ls -d *.pdf))
for f in ${a[@]} ;do
[ "${a[1]} " != "$f " ] && pdfposter -m a4 -p 2x1a4 "$f" "$f.cut"
done
b=($(ls -d *.cut))
for f in ${b[@]} ;do
pdftk $f cat 1-endwest output "$f.pdf"
done
pdftk "${a[1]}" *.cut.pdf cat output 1.pdf
###################################
# optionally cut out pages 9 and 10
pdftk 1.pdf cat 1-8 11-end output a.pdf
# concatenate all files in directory alphabetically
pdftk $(ls -1|sort -h) cat output o.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment