LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to find PDF page count (https://www.linuxquestions.org/questions/programming-9/how-to-find-pdf-page-count-699113/)

mfoley 01-22-2009 08:08 AM

how to find PDF page count
 
Does anyone know where I can look in a PDF file to find the number of pages in the document?

David the H. 01-22-2009 09:18 AM

The xpdf utilities package (called xpdf-utils in debian) includes an application called pdfinfo. It will print out the number of pages in the file, among other data.

You might also want to check out pdftk, which provides some useful tools for manipulating .pdf files.

renjithrajasekaran 01-24-2009 09:05 AM

If you are opening it manually - it will be there at the foot of the Acrobat Reader application screen.
:)

Linux Archive

H_TeXMeX_H 01-24-2009 12:28 PM

Try 'pdfinfo'.

colucix 01-24-2009 12:47 PM

Or pdftk, too:
Code:

pdftk file.pdf dump_data | grep NumberOfPages

wje_lq 01-24-2009 01:39 PM

Heck, I'll join the party. My favorite way is to use a PDF to PostScript tool, like pdf2ps. (If your system doesn't have that, just install Slackware, and you'll be all set.)
Code:

pdf2ps something.pdf something.ps
grep showpage something.ps | wc -l


mfoley 02-26-2009 01:50 PM

Someone suggested looking for /Count. That works, sort of ...

strings myfile.pdf | grep /Count

However, some files I have tested show multiple /Count entries:
/Count 1
/Count 4
/Count 1
/Count 5
/Count 1
/Count 6

In the examples I've tried, the highest number listed is the correct count. Any idea why I get multiple counts.

H_TeXMeX_H 02-26-2009 02:48 PM

Ok if you want just the number of pages do this:

Code:

pdfinfo file.pdf | grep Pages | awk '{print $2}'

colucix 02-26-2009 02:55 PM

Why bother if you have other tools at hand?
Code:

$ pdfinfo file.pdf | grep Pages
$ pdftk file.pdf dump_data | grep NumberOfPages



All times are GMT -5. The time now is 04:24 PM.