Many hours have I searched for a fast and easy, but mostly a
If you have access to shell, a simplest (but not usable on 100% of PDFs) approach would be to use grep.
This should return just the number of pages:
grep -m 1 -aoP '(?<=\/N )\d+(?=\/)' file.pdf
Example: https://regex101.com/r/BrUTKn/1
Switches description:
-m 1 is neccessary as some files can have more than one match of regex pattern (volonteer needed to replace this with match-only-first regex solution extension)-a is neccessary to treat the binary file as text-o to show only the match-P to use Perl regular expressionRegex explanation:
(?<=\/N ) lookbehind of /N (nb. space character not seen here)\d+ any number of digits(?=\/) lookahead of /Nota bene: if in some case match is not found, it's safe to assume only 1 page exists.