Solved

Command Line tool to call TIFF/PDF page counter?

Posted on 2010-11-23
8
903 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 53

Expert Comment

by:Huseyin KAHRAMAN
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 54

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 54

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
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

 
LVL 54

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 54

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 54

Expert Comment

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

~bp
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is in response to a question here (http://www.experts-exchange.com/Other/URLs/Q_28283850.html) at Experts Exchange. The Original Poster has a scanned signature and wants to make the background transparent so that the signature may be pl…
*Adobe Acrobat 9 was used for this article. Particular steps may vary depending on software versions. 1. Create a framework of your form in Word, leaving space where you’d ultimately like the Adobe fields to appear.  (Note: I use the blank lines …
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
Sometimes we receive PDF files that are in the wrong orientation. They may be sideways or even upside down. This most commonly happens with scanned or faxed documents. It is possible to rotate the view of these PDFs with the free Adobe Reader produc…

739 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