Skip to content

Instantly share code, notes, and snippets.

@zelinskiy
Created January 27, 2020 13:10
Show Gist options
  • Save zelinskiy/a0db0470e23839251829053766d468cb to your computer and use it in GitHub Desktop.
Save zelinskiy/a0db0470e23839251829053766d468cb to your computer and use it in GitHub Desktop.
#!/bin/bash
# usage:
# $ sh mksigs.sh 24 input.pdf
D=$1
INPUT=$2
I=1
N=$(qpdf --show-npages $INPUT)
SIGN=1
mkdir out_$INPUT
while [ $I -le $N ]
do
BEGIN=$I
if [ $((I+D-1)) -le $N ]
then
END=$((I+D-1))
else
END=$N
fi
echo "$BEGIN-$END"
qpdf --empty --pages $INPUT $BEGIN-$END -- out_$INPUT/sig$SIGN.ps
I=$((I+D))
SIGN=$((SIGN+1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment