watermark-pdf/watermark.sh

26 lines
679 B
Bash
Raw Normal View History

#!/bin/bash
WATERMARK_TEXT="VOTRE TEXTE À WATERMARKER"
COLOR="red"
INPUT_PDF="$1"
OUTPUT_PNGs="./pdf"
WATERMARK_SIZE=50
WATERMARK_PNG_SIZE="800x300"
convert -size ${WATERMARK_PNG_SIZE} xc:white -font Arial -pointsize ${WATERMARK_SIZE} \
-gravity NorthWest -draw "fill ${COLOR} text 70,15 '${WATERMARK_TEXT}'" \
-gravity SouthEast -draw "fill ${COLOR} text 70,150 '${WATERMARK_TEXT}'" \
stamp.png
pdftoppm ${INPUT_PDF} ${OUTPUT_PNGs} -png
for pic in *.png; do
if [ ${pic} != "stamp.png" ]; then
composite -dissolve 25% -tile stamp.png ${pic} ${pic//.png}-marked.png
fi
done
convert *-marked.png ${INPUT_PDF}-out.pdf
rm *.png