ambevar-dotfiles/.scripts/pdfsize

21 lines
410 B
Bash
Executable File

#!/bin/sh
usage () {
cat <<EOF>&2
Usage: ${0##*/} [options] <PDF-file>
Same as pdfinfo, but append size in milimeters.
EOF
}
[ $# -eq 0 ] && usage && exit 1
[ "$1" = "-h" ] && usage && exit
[ "$1" = "--" ] && shift
if ! command -v pdfinfo >/dev/null 2>&1; then
echo >&2 'pdfinfo not found'
exit 1
fi
pdfinfo "$@" | awk '/^Page size:/ {printf $0; print ", " $3*0.35278 " x " $5*0.35278 " mm"; next } 1'