dotfiles/scripts/.local/bin/pdf-clean.sh

16 lines
304 B
Bash
Raw Permalink Normal View History

2022-07-05 13:18:25 +00:00
#!/usr/bin/env dash
2022-07-05 13:43:37 +00:00
set -e
2023-02-21 13:43:37 +00:00
FILE="$1"
CLEAN="${FILE%.pdf}.clean.pdf"
2022-07-05 13:18:25 +00:00
2023-02-21 13:43:37 +00:00
pdftk "$FILE" dump_data_utf8 |
sed -E 's/^InfoValue:.*$/InfoValue:/g' |
pdftk "$FILE" update_info - output "$CLEAN"
2022-07-05 13:18:25 +00:00
2023-02-21 13:43:37 +00:00
exiftool -q -overwrite_original -all:all= "$CLEAN"
qpdf --linearize --replace-input "$CLEAN"
2022-07-05 13:18:25 +00:00
2023-02-21 13:43:37 +00:00
echo "$CLEAN"