Using pdftotext:#
Installation:
- If it’s not installed, you’ll need to install the
poppler-utilspackage which includespdftotext.
sudo apt install poppler-utilsor
yum install poppler-utilsdepending on your distribution.
- If it’s not installed, you’ll need to install the
Usage:
- Once installed, you can convert a PDF to text and then count the words as follows:
pdftotext input.pdf - | wc -wHere,
input.pdfis your source PDF file, andwc -wcounts the number of words. The-inpdftotextspecifies that the output should be sent to stdout, which is then piped intowc.