Return to Snippet

Revision: 20215
at November 10, 2009 01:05 by traeregan


Initial Code
METHOD 1
ImageMagick: identify -density 12 -format "%p" image.pdf

METHOD 2
FPDI (when setting the source file you get back the page count):
http://www.setasign.de/products/pdf-php-solutions/fpdi/demos/thumbnails/

METHOD 3
Open the pdf as a text file and count the number of times "/Page" occurs.
function count_pages($pdfname) {
  $pdftext = file_get_contents($pdfname);
  $num = preg_match_all("/\/Page\W/", $pdftext, $dummy);
  return $num;
}

Initial URL

                                

Initial Description

                                

Initial Title
Count The Number of Pages in a PDF

Initial Tags
page

Initial Language
PHP