Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Command Line tool to call TIFF/PDF page counter?

Posted on 2010-11-23
8
Medium Priority
?
907 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 60

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 58

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 58

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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
LVL 58

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
 

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 58

Accepted Solution

by:
Bill Prew earned 2000 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 58

Expert Comment

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

~bp
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ability to edit PDF documents can be useful, however it may not be a straight forward process. Many non-technical people don't realise that a PDF document is basically an image rather than a text file, even if it contains nothing but text. If…
Update 21-May-2015: I temporarily removed the source code and the code snippets to make major changes to the program. Regards, Joe INTRODUCTION This Article is a follow-up to the Article entitled How To Rename-Move a Batch of PDF Files Based o…
In this third video of the Xpdf series, we discuss and demonstrate the PDFtoText utility, which converts PDF files into plain text files. Download and install the software.: You may have already downloaded and installed the Xpdf tools while watching…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

598 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