#!/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