paper-cutter/{{cookiecutter.paper_repo_name}}/helpers/stats.sh
Filip Gralinski 67c788fe69 Init from an internal repo.
Commit d5b6f8e831fc5c933af5ceb1267f51ef6af6c438
2020-11-24 08:33:07 +01:00

19 lines
422 B
Bash
Executable File

#!/bin/bash
here_dir=$(dirname "$0")
echo $here_dir
pdf_file="$1"
if [[ "$pdf_file" == "" ]]
then
>&2 echo "no file given"
exit 1
fi
perl -e 'print "PHYSICAL PAGES\tCHARACTERS WITH SPACES\tSTANDARD PAGES\n"'
pages=$(pdfinfo "$1" | perl -ne 'print "$1\n" if /Pages:\s+(\d+)/')
chars=$(bash $here_dir/pdf-to-plain-text.sh "$1" | wc -m)
spages=$(echo "scale=1; $chars / 1800.0" | bc)
echo "$pages $chars $spages"