pdf_anonymiser.sh
author Peter Gervai <grin@grin.hu>
Fri, 03 Oct 2014 15:01:17 +0200
changeset 1 26fed0d59d7c
parent 0 624a9ab34425
permissions -rwxr-xr-x
Add dottr.pl, a Racktables topology to GraphViz converter

#!/bin/sh
#
# (cc) Peter Gervai, 2011
# cc-by-sa-3.0
#
# remove private info from PDFs
#

if [ "$1" == "" ]; then
	echo " "
	echo "pdf metadata cleaner v1.00 by Peter 'grin' Gervai, 2011"
	echo " "
	echo "Usage: $0 filename.pdf"
	echo " "
	exit 0
fi 

T=`mktemp /tmp/pdfanon.XXXXXXXX`

# clean and dump InfoKeys
pdftk "$1" dump_data |  awk '/InfoValue/ {print $1}; !/InfoValue/ {print }' > $T
# update empty keys in pdf
pdftk "$1" update_info $T output "$1_new.pdf"
mv "$1" "$1.bak"
mv "$1_new.pdf" "$1"
echo  "$1.pdf written, old one renamed to $1.bak. Have a nice day!"

rm $T