Skip to content

Instantly share code, notes, and snippets.

@ehamberg
Created January 6, 2012 14:34
Show Gist options
  • Select an option

  • Save ehamberg/1570848 to your computer and use it in GitHub Desktop.

Select an option

Save ehamberg/1570848 to your computer and use it in GitHub Desktop.
Script for downloading and combining the chapters of “Ηandbook of applied cryptography” to one pdf file
#!/bin/bash
# downloads all chapters of “handbook of applied cryptography”
# (<http://www.cacr.math.uwaterloo.ca/hac/>) and combines them into one pdf file.
# The resulting file can not be distributed and is only for personal use, as
# per the copyright notice at
# <http://www.cacr.math.uwaterloo.ca/hac/about/copyright-notice.html>.
# Requires ghostscript.
TEMPDIR="/tmp"
# download all chapters
for i in chap{1..15} index references appendix ; do
wget http://www.cacr.math.uwaterloo.ca/hac/about/${i}.pdf
done
# remove the first page from all chapters so page numbers will be correct
for i in *.pdf ; do
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dFirstPage=2 \
-sOutputFile=${TEMPDIR}/_${i} $i
done
# combine all chapters to one pdf file
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \
-sOUTPUTFILE=handbook_of_applied_cryptography.pdf \
${TEMPDIR}/_chap?.pdf ${TEMPDIR}/_chap??.pdf ${TEMPDIR}/_appendix.pdf \
${TEMPDIR}/_references.pdf ${TEMPDIR}/_index.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment