Link to home
Start Free TrialLog in
Avatar of pelampe
pelampeFlag for United States of America

asked on

Can you find number of pages on PDF without opening it?

Hello,

Is there a way to find out how many pages a PDF is WITHOUT opening it?

I have found out that a bunch of scanned docs to PDF were scanned incorrectly and only the first page was scanned instead of the normal 3-5 pages.  We are talking about a couple of hundred possibly have been scanned incorrectly, out of a total of 900.  If I could find ALL of the PDF's that were only ONE page, then I could re-assign the task to the clerk and have those re-scanned.

Is this possible?

Thanks in advance for your answers!

Phil
Avatar of Karl Heinz Kremer
Karl Heinz Kremer
Flag of United States of America image

That depends on your definition of "opening"... You cannot determine the number of pages without opening the file - software needs to read the document in order to determine how many pages are in it. However, this can be done without manually opening the file in Acrobat (or Reader).

If you have the full version of Acrobat, you could run a batch sequence (assuming that all 900 documents are in one, or in a very limited number of directories). The batch sequence would run a JavaScript program to read the number of pages, and if it's 1, it would print a message to a file.

If you don't want to get into JavaScript (or don't have the full version of Acrobat), you could use the free pdftk (http://www.accesspdf.com/pdftk/) and use a batch script to run the program on all your files. If you use the "dump_data" command, it will report the number of pages in the document:

C:\temp>pdftk test.pdf dump_data
InfoKey: Creator
InfoValue: PScript5.dll Version 5.2
InfoKey: Title
InfoValue: Microsoft Word - test.doc
InfoKey: HDIG_ModDate
InfoValue: D:20060616141835-04'00'
InfoKey: Producer
InfoValue: GNU Ghostscript 7.05
InfoKey: Author
InfoValue: Noel
InfoKey: CreationDate--Text
InfoValue: 11/18/2005 15:17:16
InfoKey: ModDate
InfoValue: D:20060616141835-04'00'
InfoKey: CreationDate
InfoValue: 11/18/2005 15:17:16
PdfID0: 23d2e8ee9b1aab4c93252af6d89f57f6
PdfID1: 23d2e8ee9b1aab4c93252af6d89f57f6
NumberOfPages: 15


As you can see, the last line contains the number of pages in the document.

All you need to do is to come up with a script that can run this program on all files and evaluate the output line that starts with "NumberOfPages:".
Avatar of pelampe

ASKER

OK. I've downloaded the pdftk and it is working fine.  But how to write a batch program is well beyond my realm of knowledge.  Can you provide me with any hints or info as to how to go about it?

BTW, I do also have the FULL version of Acrobat 7, FWIW.
ASKER CERTIFIED SOLUTION
Avatar of Karl Heinz Kremer
Karl Heinz Kremer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pelampe

ASKER

Karl,

WOW!  Worked fantastic!

I am increasing your points too.

Thanks for your help!

Phil