pdf_anonymiser.sh
changeset 0 624a9ab34425
equal deleted inserted replaced
-1:000000000000 0:624a9ab34425
       
     1 #!/bin/sh
       
     2 #
       
     3 # (cc) Peter Gervai, 2011
       
     4 # cc-by-sa-3.0
       
     5 #
       
     6 # remove private info from PDFs
       
     7 #
       
     8 
       
     9 if [ "$1" == "" ]; then
       
    10 	echo " "
       
    11 	echo "pdf metadata cleaner v1.00 by Peter 'grin' Gervai, 2011"
       
    12 	echo " "
       
    13 	echo "Usage: $0 filename.pdf"
       
    14 	echo " "
       
    15 	exit 0
       
    16 fi 
       
    17 
       
    18 T=`mktemp /tmp/pdfanon.XXXXXXXX`
       
    19 
       
    20 # clean and dump InfoKeys
       
    21 pdftk "$1" dump_data |  awk '/InfoValue/ {print $1}; !/InfoValue/ {print }' > $T
       
    22 # update empty keys in pdf
       
    23 pdftk "$1" update_info $T output "$1_new.pdf"
       
    24 mv "$1" "$1.bak"
       
    25 mv "$1_new.pdf" "$1"
       
    26 echo  "$1.pdf written, old one renamed to $1.bak. Have a nice day!"
       
    27 
       
    28 rm $T