Skip to content

Instantly share code, notes, and snippets.

@megahall
Created October 23, 2024 19:01
Show Gist options
  • Save megahall/978fb47bda2ac2a6a541558578442702 to your computer and use it in GitHub Desktop.
Save megahall/978fb47bda2ac2a6a541558578442702 to your computer and use it in GitHub Desktop.
Watermark Your PDF With A Specific String In Linux
#!/bin/bash
watermark="${1}"
shift
wm_pdf="$(mktemp -t watermark_XXXXXX.pdf)"
convert -background none -fill "rgba(128, 128, 128, 0.7)" -gravity center -font Arial -pointsize 96 "label:${watermark}" -bordercolor none -border 10x10 "${wm_pdf}"
for input in "$@"; do
output="$(basename "${input}" .pdf)_wm.pdf"
qpdf --overlay "${wm_pdf}" --repeat=1 -- "${input}" "${output}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment