zoukankan      html  css  js  c++  java
  • 关于读取pdf文件信息

    最近项目有个读取pdf页码的需求,试过老多方法,最终:

    function get_pages($document){
                $cmd = "/usr/bin/pdfinfo";           // Linux
                // $document 这是文件路径
                exec("$cmd "$document"", $output);
                $pagecount = 0;
                foreach($output as $op)
                {
                    // Extract the number
                    if(preg_match("/Pages:s*(d+)/i", $op, $matches) === 1)
                    {
                        $pagecount = intval($matches[1]);
                        break;
                    }
                }
                return array(true,$pagecount);
                
            }
    

    这是安装 pdfinfo的方法:  

    yum install poppler-utils

  • 相关阅读:
    JS函数式编程【译】前言
    11.15周总结
    11.13
    11.12
    11.11
    11.10
    11.9
    11.8周总结
    11.6
    11.5
  • 原文地址:https://www.cnblogs.com/wfc139/p/15263363.html
Copyright © 2011-2022 走看看