pdf_anonymiser.sh
author Peter Gervai <grin@grin.hu>
Wed, 15 May 2024 09:50:23 +0200
changeset 14 d2d8803e35ec
parent 0 624a9ab34425
permissions -rwxr-xr-x
pwgen.pl: support "hungarian-friendly" speaker mode, basically getting rid of 'qxy' with a given probability

#!/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