Home > Backend Development > PHP Tutorial > FBI teaches you how to read minds pdf How to simply read the number of PDF pages using PHP

FBI teaches you how to read minds pdf How to simply read the number of PDF pages using PHP

WBOY
Release: 2016-07-27 16:56:21
Original
1497 people have browsed it

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;
    }
}

Copy after login

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template