Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
01-22-2009, 08:08 AM
|
#1
|
|
Member
Registered: Oct 2008
Posts: 52
Rep:
|
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?
|
|
|
|
01-22-2009, 09:18 AM
|
#2
|
|
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,577
|
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.
|
|
|
|
01-24-2009, 09:05 AM
|
#3
|
|
Member
Registered: Jan 2009
Posts: 29
Rep:
|
If you are opening it manually - it will be there at the foot of the Acrobat Reader application screen.
Linux Archive
Last edited by renjithrajasekaran; 01-25-2009 at 03:06 AM.
|
|
|
|
01-24-2009, 12:28 PM
|
#4
|
|
Guru
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,610
|
Try 'pdfinfo'.
|
|
|
|
01-24-2009, 12:47 PM
|
#5
|
|
Moderator
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.4 OpenSuSE 12.2
Posts: 9,896
|
Or pdftk, too:
Code:
pdftk file.pdf dump_data | grep NumberOfPages
|
|
|
|
01-24-2009, 01:39 PM
|
#6
|
|
Member
Registered: Sep 2007
Location: Mariposa
Distribution: Debian lenny, Slackware 12
Posts: 806
Rep: 
|
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
|
|
|
|
02-26-2009, 01:50 PM
|
#7
|
|
Member
Registered: Oct 2008
Posts: 52
Original Poster
Rep:
|
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.
|
|
|
|
02-26-2009, 02:48 PM
|
#8
|
|
Guru
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,610
|
Ok if you want just the number of pages do this:
Code:
pdfinfo file.pdf | grep Pages | awk '{print $2}'
|
|
|
|
02-26-2009, 02:55 PM
|
#9
|
|
Moderator
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.4 OpenSuSE 12.2
Posts: 9,896
|
Why bother if you have other tools at hand?
Code:
$ pdfinfo file.pdf | grep Pages
$ pdftk file.pdf dump_data | grep NumberOfPages
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 07:44 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|