Page 1 of 1
Counting Pages
Posted: Mon Feb 22, 2010 10:20 am
by usamaalam
Hello Everybody,
Is there a way to count total number of pages of word and pdf files with PHP?
Thanks.
Re: Counting Pages
Posted: Mon Feb 22, 2010 10:41 am
by AbraCadaver
Lots of ways using directoryiterator or readdir, but depending upon what you need to do, I like glob():
Code: Select all
$count = count(glob('/dir/{*.pdf,*.doc}', GLOB_BRACE));
Re: Counting Pages
Posted: Mon Feb 22, 2010 11:26 am
by josh
Thats not what he asked
Re: Counting Pages
Posted: Mon Feb 22, 2010 1:48 pm
by AbraCadaver
josh wrote:Thats not what he asked
Ahh, I see. That will count the total number of files, not pages within the files if that's what you wanted.

Re: Counting Pages
Posted: Mon Feb 22, 2010 4:03 pm
by josh
usamaalam, I would look into command line Open Office. I don't know if it does what you want for sure, but it does a lot. I know for a fact I can convert doc to pdf in OO. Then I know for a fact I can use posttext imagemagick extension to convert each page to a JPG. Then I could glob and count the jpgs.
Maybe some one has a clearer solution, or maybe Open Office has a way to get the page count already. Do report back with what you find.