summaryrefslogtreecommitdiff
path: root/mktxt-default
blob: 9c2e422adce6b9b3ce5ff254a50c392f9cd4ade7 (plain)
  1. #!/bin/sh
  2. # convert text from PDF to text
  3. set -e
  4. # resolve options
  5. eval set -- "$(getopt -s sh -o f -- "$@")"
  6. while true; do case "$1" in -f) force=1; shift;; --) shift; break;; esac; done
  7. . /lib/lsb/init-functions
  8. log_action_begin_msg "Convert PDF → text"
  9. for stem in "$@"; do
  10. infile=$stem.pdf
  11. outfile=$stem.txt
  12. log_action_cont_msg $stem
  13. [ -n "$force" ] || [ ! -f $outfile ] || [ $outfile -ot $infile ] || [ $outfile -ot "$0" ] || { log_warning_msg "skipped"; continue; }
  14. pdftotext -raw -nopgbrk $stem.pdf $outfile
  15. done
  16. log_action_end_msg $?