Get number of pages in a pdf using a cmd batch file

Viewed 56755

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?

7 Answers

It might be helpful for new users. In the new version of PDFtk tool (above 2.0), use below command to get the number of pages of a PDF file:

pdftk file.pdf dump_data_annots output outputfile.txt

A new file will created at destination having content similar to below:

NumberOfPages: 6

Now read the file and manipulate the content as you want.

I know this is old post, yet still very much relevant, so I believe that there should be an answer which can tell how to get page count using "poppler-0.68.0" utility, in windows.

Navigate to bin folder and run pdfinfo.exe like - C:\Temp\temp_folder\poppler-0.68.0\bin>pdfinfo.exe "C:\Temp\temp_folder\TT.pdf"

Code in action

Related