Page 1 of 1

Count number of pages in PDF file

Posted: 2011-09-19T00:54:47-07:00
by blasteralfred
Hi,

I am using PHP 5 with Apache 2 in my Windows Vista PC. I have Imagemagick already installed and configured. I want to count the total number of pages in a pdf file using imagick.

Can somebody give me a clear and complete solution to count pages using imagemagick? (i am a beginner)

From googling, I found some examples;

Code: Select all

imagick(identify -format %n testfile.pdf) 

Code: Select all

identify -density 12 -format "%p" testfile.pdf 

Code: Select all

identify -format %n testfile.pdf 
I don't know how to make use of this stuff..

Thanks in advance... :)

blasteralfred

Re: Count number of pages in PDF file

Posted: 2011-09-19T08:45:22-07:00
by Bonzo
Not sure how it works with Imagick but this will work for Imagemagick and the command line:

Code: Select all

$pages = exec("identify -format %n testfile.pdf");

echo $pages;
You could see if you can work out how to use imagick to do the above with the info here: http://uk3.php.net/imagick