Skip to content

Instantly share code, notes, and snippets.

@wcasanova
Forked from bikz05/remove_txt
Created July 12, 2018 02:28
Show Gist options
  • Save wcasanova/44162e448154002957e7edb8d5f2a667 to your computer and use it in GitHub Desktop.
Save wcasanova/44162e448154002957e7edb8d5f2a667 to your computer and use it in GitHub Desktop.
Shell script to remove text from PDF using pdftk
echo $"Script Written by $(tput setaf 5)Bikram Hanzra$(tput sgr 0) (bikz.05@gmail.com)"$
if [ "$#" == 0 ] ; then
echo "$(tput setaf 1)We need at least 2 arguments"
echo "SYNTAX ./remove <file-name> <text-to-be-removed>"
echo "<text-to-be-removed> by default = www.it-ebooks.info$(tput sgr 0)"
exit
fi
if [ "$#" == 1 ] ; then
echo "$(tput setaf 1)CAVEAT$(tput sgr 0) -> Will remove occurances of -> $(tput setaf 1)"www.it-ebooks.info"$(tput sgr 0)"
set -- "${@:1}" "www.it-ebooks.info"
fi
# Display files names
echo "$(tput setaf 4)File Name ->" "$1"$'\n'"Text to be removed-> " "$2 $(tput sgr 0)"
# Include the watermark
sed -e "s/"$2"/ /g" <"$1" >unwatermarked.pdf && pdftk unwatermarked.pdf output fixed.pdf && mv fixed.pdf unwatermarked.pdf
mv unwatermarked.pdf "$1"
echo "$(tput setaf 4)Removing Watermark Successful :)$(tput sgr 0)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment