tags:

views:

289

answers:

2

I can see there are a lot of questions for getting the number of pages in a a pdf with c, PHP and others but am wondering with a batch file or cmd is there a simple way of getting hte number of pages?

+1  A: 

Using pdftk pdftk my.pdf dump_data | grep NumberOfPages does the trick.

Tuure Laurinolli
Substitute `grep` by `findstr` and you even run on Windows without having to install more than pdftk.
Joey
+1  A: 

Hi Tuuri and other guys, could you please tell me how to use "pdftk mypdf.pdf dump data | findstr NumberOfPages in powerbuilder run command and save this metadata in a file by using the following code like this:

string ls_runinput, ls_outputfile

ls_outputfile = "c:\test.exe"
ls_runinput = "c:\pdftk\pdftk.exe mypdf.pdf dump_data | findstr NumberPages >" + ls_outputfile
Run(ls_runinput,Minimized!)
li_fileopen = FileOpen(ls_outputfile ,TextMode!, Read!, Shared!)

The problem is that Run command is executed, the file is created, but fileopen return -1 ?

Is it maybe that run cannot recognize the "|" character?

What should you propose me to write the right code?

Iam using powerbuilder 10.5.2 , Thanks very much in advance

sgian76