The example in this article describes the implementation method of simply reading the number of PDF pages in PHP. I share it with you for your reference. The details are as follows:
Foreigners are more kind. I found such a method on the foreigner's website.
I wrote it into a function, and then wrote the function into the PdfUtil class in my own LeeLib library.
Very simple way, the speed is pretty good.
/** * 获取PDF的页数 */ function getPageTotal($path){ // 打开文件 if (!$fp = @fopen($path,"r")) { $error = "打开文件{$path}失败"; return false; } else { $max=0; while(!feof($fp)) { $line = fgets($fp,255); if (preg_match('/\/Count [0-9]+/', $line, $matches)){ preg_match('/[0-9]+/',$matches[0], $matches2); if ($max<$matches2[0]) $max=$matches2[0]; } } fclose($fp); // 返回页数 return $max; } }
Readers who are interested in more PHP related content can check out the special topics of this site: "php file operation summary", "php regular expression usage summary", "php operation Summary of office document skills (including word, excel, access, ppt)", "Comprehensive collection of PHP array (Array) operation skills", "Summary of PHP sorting algorithm", "Summary of PHP common traversal algorithms and techniques", "PHP data structure and algorithm Tutorial", "php Programming Algorithm Summary", "PHP Mathematical Operation Skills Summary", "PHP Operations and Operator Usage Summary", "php String Usage Summary" and "php Common Database Operation Skills Summary"
I hope this article will be helpful to everyone in PHP programming.
The above introduces the implementation method of fbi teaches you how to read minds pdf PHP to simply read the number of PDF pages, including the content of fbi teaches you how to read minds pdf. I hope it will be helpful to friends who are interested in PHP tutorials.