Last active
September 29, 2021 17:40
-
-
Save VHarisop/3e259552cdc2e34942cd7069ae996f17 to your computer and use it in GitHub Desktop.
Strip user metadata from PDF by linearizing the output of exiftool.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function usage() { | |
cat << 'EOF' | |
Usage: | |
linearize_pdf.sh --file <input_file> --output <output_file>. | |
Arguments: | |
-f, --file: Input .pdf file to be processed. | |
-o, --output: Name of output .pdf file. | |
Notes: | |
- Assumes `exiftool` and `qpdf` are available and in the user's $PATH. | |
EOF | |
} | |
while [[ $# -gt 0 ]] | |
do | |
key="$1" | |
case ${key} in | |
-f|--file) | |
shift | |
INFILE="$1" | |
;; | |
-o|--output) | |
shift | |
OUTFILE="$1" | |
;; | |
-h|--help) | |
usage | |
exit | |
;; | |
*) | |
usage | |
exit 1 | |
esac | |
shift | |
done | |
exiftool -all= -overwrite_original ${INFILE} | |
qpdf --linearize ${INFILE} ${OUTFILE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment