I am using the following code to get the number of pages in a PDF file.
$img = new imagick();
$img->setResolution(200,200);
$img->readImage("{$FileName}");
$NumberOfPages = $img->getNumberImages();
echo "$NumberOfPages";
The code works but is very slow (0.5 seconds per page. A 29 page PDF takes 15 seconds to deliver the result).
Am I missing something? There must be a faster way to:
1) Get the number of pages in a pdf
2) Convert a single page to an image
Please note that 2) is possible only after 1) is accomplished. No point in converting, say, page 39, when the PDF only has 16 pages.
Any help would be much appreciated.
David