dotfiles/.local/bin/scripts/sign

16 lines
646 B
Plaintext
Raw Normal View History

#!/bin/sh
signature=$(pass tools/signature)
# TODO make filenames unique and don't rerun unneccessarily
tmp_base=/tmp/sign
mkdir -p $tmp_base
tmp_signed=$tmp_base/$1_last-signature.pdf
tmp_reversed=$tmp_base/$1_reverse.pdf
sig=$tmp_base/signature_offset.pdf
result="${1%.pdf}_signed.pdf"
pdfjam "$signature" --outfile "$sig" --offset "${2:-0}pt ${3:-0}pt" --papersize "{595pt, 842pt}" --noautoscale true --scale "${4:-1}"
pdfjam "$1" last "$sig" --outfile "$tmp_signed" --delta "0 -842pt" --nup "1x2" --fitpaper true
pdfjam "$1" last-1 --outfile "$tmp_reversed"
pdfjam "$tmp_reversed" last-2 "$tmp_signed" --outfile "$result"
xdg-open "$result"