watermark-pdf/watermark.sh
Louis Vallat 9be7d62d59
Initial commit
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
2021-12-15 18:56:10 +01:00

26 lines
679 B
Bash
Executable File

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