pdftotext -l $(pdfinfo "File.pdf" | grep Pages | awk '{print $2-1}') "File.pdf" -| wc -w
Replace File.pdf with the name of your file
File.pdf