Skip to content

Instantly share code, notes, and snippets.

@pachadotdev
Last active August 7, 2020 16:53
Show Gist options
  • Save pachadotdev/16c0fc09acca268dfe395b936a92e085 to your computer and use it in GitHub Desktop.
Save pachadotdev/16c0fc09acca268dfe395b936a92e085 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -o nounset
case "${1:-}" in
--)
pdf="$2"
html="${pdf%.pdf}".html
dest="${html}".gz
[ -e "$dest" ] && exit
pdftohtml -nodrm -s -i -noframes -stdout "$pdf"
if grep <"$html" -E -v 'PADRÓN +AUDITADO +PLEBISCITO +NACIONAL +2020' | gzip -9 >"$dest"; then
rm -vf "$html"
fi
;;
*)
tsp pdftohtml -S 8
for x in *.pdf; do
tsp pdftohtml "${BASH_SOURCE[0]}" -- "$x"
done
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment