-
-
Save wcasanova/44162e448154002957e7edb8d5f2a667 to your computer and use it in GitHub Desktop.
Shell script to remove text from PDF using pdftk
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
echo $"Script Written by $(tput setaf 5)Bikram Hanzra$(tput sgr 0) ([email protected])"$ | |
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