PHP - Count Number of Pages in PDF

PHP

Nicesnippets

251

06-02-2020


This tutorial will give you example of how to get number of pages in pdf file using php. if you have question about get number of pages in pdf then i will give simple example with solution this example will help you get number of pages in pdf with php. it's simple example of get number of page views Follow bellow tutorial step of how to get number of pages in pdf file.

I will you get to number of pages in pdf.you can simply use this function in php. follow bellow example.

Example :

<?php

function count_pages($pdfname) {

$pdftext = file_get_contents($pdfname);

$num = preg_match_all("/\/Page\W/", $pdftext, $dummy);

return $num;

}

$pdfname = 'pdf/dummy.pdf';

$pages = count_pages($pdfname);

echo $pages;

?>

It will help you....