How to remove watermark in PDF


Here I will show you how is easy to remove a watermark from PDF file.

      This watermarks you can see many time in PDF eBooks which you can download from free Internet resources. Some Web site owners to keep trademark and make users to come back again – using a tricks as inserting website URL address into PDF document. Its really make some time annoying as you don’t want your copy of eBook will be looks like second hand but as original PDF from Publisher company.

      Let say – You’ve downloaded many PDF files from one of internet resource ( Example: www.it-ebooks.info). All your PDF eBooks are stamped by some word in each pages. This is actually is TEXT object in PDF script file which is possible to remove using right way of binary compatible parsing mechanism. Most UNIX/Linux like Shell utilities can not proper fetch all strings in STDINPUT and write it back to STDOUT to the file cause of binary meta tags in PDF file.

      I’ve wrote some simple easy fast script which removing the watermark word string in all PDF files from required folder. You just need to provide a folder path as an input parameter and script will show you which PDF file the watermark has been removed
The script will provide verbose output to the console. Additionally – you need just modify the script to write the exact watermark word string.

Script PDF_watermark_remover.sh:

 

#!/bin/bash

source_dir=$1;

find “$1″ -type f -name “*.pdf” -print0|while read -d $’\0′ file;

do

if [ `strings “$file”|grep -c “www.it-ebooks.info”` -gt 0 ];—- Replace it with required word string

then

echo “$file”;

cp “$file” /tmp/1.pdf;

script=$(cat <<‘EOF’

use strict;

use warnings;

open(my $in, ‘<‘, ‘/tmp/1.pdf’)

or die “Cannot open input.txt: $!”;

open(my $out, ‘>’, ‘/tmp/2.pdf’)

or die “Cannot open output.txt: $!”;

while (<$in>) {

print $out $_ unless /www.it-ebooks.info/; —- Replace it with required word string

}

close($in);

close($out);

EOF

)

/usr/bin/perl -e “$script”

mv -v /tmp/2.pdf “$file”;

rm /tmp/1.pdf

fi;

done

 

To run this script – simple run it with full path to folder where all your PDF files is located as input parameter:

# PDF_watermark_remover.sh ~/Documents/PDF

/Users/user1/Documents/PDF/file1.pdf
/tmp/2.pdf -> /Users/user1/Documents/PDF/file1.pdf
/Users/user1/Documents/PDF/file2.pdf
/tmp/2.pdf -> /Users/user1/Documents/PDF/file2.pdf
/Users/user1/Documents/PDF/file3.pdf
/tmp/2.pdf -> /Users/user1/Documents/PDF/file3.pdf

 

Don’t forget to give executable permission to the script:

# chmod +x PDF_watermark_remover.sh

 

Thanks,

Eldar Aydayev