PHP simple to read PDF page implementation method _php tips

Source: Internet
Author: User
Tags php regular expression

This article illustrates how PHP simply reads PDF pages. Share to everyone for your reference, specific as follows:

Or foreigners more honest, in the foreigner's website found such a way,

I wrote a function to write the function into the Pdfutil class in my Leelib library.

In a very simple way, the speed is good.

/**
* Get PDF pages *
/
function Getpagetotal ($path) {
    //Open File
    if (! $fp = @fopen ($path, "R")) {
      $ Error = "Open file {$path} failed";
      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], $matches 2);
          if ($max < $matches 2[0]) $max = $matches 2[0];
        }
      Fclose ($FP);
      Returns the number of pages return
      $max;
    }
}

More about PHP Interested readers can view the site topics: "PHP file Operation Summary", "PHP Regular Expression Usage summary", "PHP operation Office Document Skills Summary (including word,excel,access,ppt)", "PHP Arrays (Array) Operation Skills Daquan, "Summary of PHP sorting algorithm", "PHP common traversal algorithm and skills summary", "PHP Data structure and algorithm tutorial", "PHP Program Design Algorithm Summary", "PHP Mathematical Calculation Skills Summary", "PHP operation and operator Usage Summary", "PHP string" (String Summary of usage and PHP common database operation Skills Summary

I hope this article will help you with the PHP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.