I can see there are a lot of questions for getting the number of pages in a a pdf with C, PHP and others but am wondering with a batch file or cmd is there a simple way of getting the number of pages?
Method 1: Check Details in File Folder Then open the file folder and click “More options” button next to “Change your view”. Next click “Details”. Now right click on the header row and choose “More”. In the “Choose Details” dialog box, check “Pages” and “Word count” boxes.
Using pdftk:
pdftk my.pdf dump_data | grep NumberOfPages
does the trick.
Alternatively you can use the command, which returns only the number:
pdfinfo "${PDFFILE}" | grep Pages | sed 's/[^0-9]*//'
You will need the poppler package:
https://poppler.freedesktop.org/
Which can be installed using either homebrew / linuxbrew:
brew install poppler
or with apt
:
sudo apt install poppler-utils
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With