Created
January 26, 2014 17:29
-
-
Save x2q/8636207 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
input="$1" | |
count=$2 | |
blank=$((count - 1)) | |
output="${1%.pdf}-header.pdf" | |
pagenum=$(pdftk "$input" dump_data | grep "NumberOfPages" | cut -d":" -f2) | |
(for i in $(seq "$blank"); do echo; done) | enscript -L1 -B --output - | ps2pdf - > /tmp/pa$$.pdf | |
(for i in $(seq "$pagenum"); do echo; done) | enscript -a ${count}- -L1 -F Helvetica@10 --header='||Page $% of $=' --output - | ps2pdf - > /tmp/pb$$.pdf | |
pdfjoin --paper letter --outfile /tmp/join$$.pdf /tmp/pa$$.pdf /tmp/pb$$.pdf &>/dev/null | |
cat /tmp/join$$.pdf | pdftk "$input" multistamp - output "$output" | |
rm /tmp/pa$$.pdf | |
rm /tmp/pb$$.pdf | |
rm /tmp/join$$.pdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment