Created
March 14, 2024 10:29
-
-
Save nherbaut/53d5870bcb2e37933efd6ff5fee80db8 to your computer and use it in GitHub Desktop.
watermark pdf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check for correct usage | |
if [ "$#" -ne 2 ]; then | |
echo "Usage: $0 input_pdf output_pdf" | |
exit 1 | |
fi | |
# Assign command line arguments to variables | |
input_pdf=$1 | |
output_pdf=$2 | |
# Specify the footer PDF file | |
footer_pdf="footer.pdf" | |
temp_output="temp_output.pdf" | |
temp_pdf="temp_%04d.pdf" | |
pdftk "$input_pdf" burst output "$temp_pdf" | |
for page_pdf in temp_*.pdf; do | |
pdftk $page_pdf multistamp $footer_pdf output "${page_pdf%.pdf}_watermarked.pdf" | |
done | |
pdftk temp_*_watermarked.pdf cat output "$output_pdf" | |
rm -rf temp_*.pdf temp_*_watermarked.pdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment