_Assumes you are on OSX (sorry, I didn't have time to test it on linux)
- PDFKit for Mac 10.11
brew install imagemagickbrew install gs
./watermark.sh mydoc.pdf < recipients.txt
_Assumes you are on OSX (sorry, I didn't have time to test it on linux)
brew install imagemagickbrew install gs./watermark.sh mydoc.pdf < recipients.txt
| #!/bin/bash | |
| mkdir out | |
| filename=$(basename "$1") | |
| extension="${filename##*.}" | |
| filename="${filename%.*}" | |
| while read line | |
| do | |
| echo "Watermarking $line" | |
| convert -background transparent \ | |
| -fill rgba\(0,0,0,0.12\) -rotate 45 \ | |
| -pointsize 96 label:"$line - Confidential" \ | |
| -trim +repage watermark.pdf | |
| output="$filename-${line//[[:blank:]]/}" | |
| echo "Saving to $output.pdf" | |
| pdftk $1 multistamp watermark.pdf output out/$output.pdf | |
| done | |
| rm watermark.pdf | |