Solved

Command Line tool to call TIFF/PDF page counter?

Posted on 2010-11-23
8
889 Views
Last Modified: 2012-05-10
Hello experts,

I have a desire to count the pages of a PDF file from the command line.  Is anyone aware of a program that could do this?  Or a command that could potentially do this?

Thanks in advance?
0
Comment
Question by:robthomas09
  • 5
  • 2
8 Comments
 
LVL 51

Expert Comment

by:HainKurt
ID: 34199130
do you want to get how many pages (a numeric value) are there in a pdf file, or create an image? can you please elaborate more...
0
 
LVL 51

Expert Comment

by:Bill Prew
ID: 34200066
If you wait another month you can get a free tool that does this from:

http://counter.tiff-tools.com/

~bp
0
 
LVL 51

Expert Comment

by:Bill Prew
ID: 34200199
Here's a way to do it in VB Script if that is useful to you?

~bp

iPages = PageCount("C:\_temp\ctt2.pdf")
Wscript.Echo iPages
Wscript.Quit

Function PageCount(sFile)
    Set oPDF = CreateObject("AcroExch.PDDoc")
    If oPDF.Open(sFile) Then
        PageCount = oPDF.GetNumPages()
        Set oPDF = Nothing
    Else
        PageCount = -1
    End If
End Function

Open in new window

0
 
LVL 51

Expert Comment

by:Bill Prew
ID: 34200261
You can also grab a copy of pdfinfo.exe at the following link, and parse the output from it in a FOR statement (let me know if you want help with that) to get the page count in a batch script.

ftp://ftp.foolabs.com/pub/xpdf/xpdf-3.02pl5-win32.zip

~bp
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:robthomas09
ID: 34200779
Thank you everyone for your replies.  We are actually running a program called Mirth, an hl7 interface engine, where we can use Javascript to execute a command line statement.  We are looking to count the pages of a particular PDF, and return a numeric value that represents how many pages it has.
Thanks!
0
 
LVL 51

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 34201242
Okay, here's a simple approach.  First, save this code as a small VBS file, lets call it PDFPAGES.VBS.

Set oPDF = CreateObject("AcroExch.PDDoc")
If oPDF.Open(WScript.Arguments.Item(0)) Then
   Wscript.Echo oPDF.GetNumPages()
Else
   Wscript.Echo -1
End If

Open in new window

Then from your Javascript mode, run the following command line:

CSCRIPT //NOLOGO PDFPAGES.VBS "c:\temp\filename.pdf"

where the PDF file that you want to get the page count is last on the command line.  The VB script will run, and display to the console the number of pages.  You will need to trap that in the javascript and grab it (I'm not a javascript jock).

~bp
0
 

Author Closing Comment

by:robthomas09
ID: 34234258
Thanks for your hard work bp - golden.
0
 
LVL 51

Expert Comment

by:Bill Prew
ID: 34234422
Great, glad that was useful, thanks.

~bp
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Power PDF (http://www.nuance.com/for-business/document-imaging-and-scanning/power-pdf-converter/index.htm) is the newest product from the Document Imaging division of Nuance Communications (http://www.nuance.com/). It is available in two editions — …
PaperPort is a popular document imaging/management product from Nuance Communications (http://www.nuance.com/). It is in widespread use by both individuals (http://www.nuance.com/for-individuals/by-product/paperport/index.htm) and businesses (http:/…
In this first video of the three-part Xpdf series, we introduce and describe Xpdf, a library containing nine command line utilities that perform various functions on PDF files. We show where the library is located and how to download it, discuss its…
In this video, we show how to perform Bates Numbering/Stamping of PDF documents using Power PDF Advanced, the newest product from the Document Imaging division of Nuance Communications. There are two editions of Power PDF — Standard and Advanced. Th…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now