dotfiles/bin/fs-watermark
2020-07-18 15:11:20 +02:00

29 lines
712 B
Fish
Executable File

#!/usr/bin/env fish
set watermark watermark.tex
set preface preface.pdf
function gen_watermark
set -l id (random)
cat "$watermark" | string replace -a "{{person}}" "$argv[1]" > "$id.tex"
pdflatex "$id.tex" > /dev/null
pdflatex "$id.tex" > /dev/null #run twice for transparency
# remove log and aux file
rm $id.aux $id.log $id.tex
echo "$id.pdf"
end
function assemble
set -l id (random)
set watermark_file (gen_watermark $argv)
echo pdftk "$argv[2]" stamp "$watermark_file" output "$id.pdf"
pdftk "$argv[2]" stamp "$watermark_file" output "$id.pdf"
pdftk "$preface" "$id.pdf" output "$id"-marked.pdf
# clean up files
rm "$watermark_file"
rm "$id.pdf"
echo "$id"-marked.pdf
end
assemble $argv