For this recipe we need ghostscript which is/should be installed by default, as well as pdftk and xpdf-utils:
apt-get install pdftk sudo apt-get install xpdf-utils
If the PDF is encrypted with a password, remove it using xpdf-utils and ghostscript:
pdftops -upw PASSWORD encrypted.pdf ps2pdf encrypted.ps plaintext.pdf
Now remove the watermark with sed and repair it with pdftk, assuming the file name is plaintext.pdf
sed -e "s/THISISTHEWATERMARK/ /g" <plaintext.pdf >nowatermark.pdf && pdftk nowatermark.pdf output repaired.pdf && mv repaired.pdf nowatermark.pdf
Resulting in the finalĀ nowatermark.pdf without encryption or watermark
Hello Roy,
Thanks for sharing the great tip.
Best Regards
I have tried to follow your advice to remove watermark from a pdf file. The name of the file is usb.pdf . I have written the following in Terminal.
sed -e “s/THISISTHEWATERMARK/ /g” nowatermark.pdf && pdftk nowatermark.pdf output repaired.pdf && mv repaired.pdf nowatermark.pdf
But it says :
bash: usb.pdf: No such file or directory
Kindly advice if I have done anything wrong.
Sounds like your command is not quite right, but without seeing the exact command I can not identify the problem.