These are at least 2 possible solutions how to get the total number of pages that are in a PDF file.
Requirements: ImageMagick

Option #1
[code language="bash"]
convert Test.pdf - | grep -a Count
[/code]

Output:
[code language="bash"]
/Count 3
[/code]

Option #2
identify Test.pdf
Output:
[code language="bash"]
Test.pdf[0] PDF 612x792 612x792+0+0 PseudoClass 256c 16-bit 1.38694mb
Test.pdf[1] PDF 612x792 612x792+0+0 PseudoClass 256c 16-bit 1.38694mb
Test.pdf[2] PDF 612x792 612x792+0+0 PseudoClass 256c 16-bit 1.38694mb
[/code]

The tests are performed on
[code language="bash"]
uname -a
Linux server 2.6.25.6-27.fc8 #1 SMP Fri Jun 13 18:20:54 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux
[/code]

Referral Note: When you purchase through a referral link (if any) on this page, we may earn a commission.
If you're feeling thankful, you can buy me a coffee or a beer