php statistics doc docx document page number

Convert doc docx to pdf

yum install unoconv 

 

unoconv -f pdf  1.docx
unoconv -f pdf  33.doc
public static function getPdfPages($path){
    if(!file_exists($path)) return array(false,"文件\"{$path}\"不存在!");
    if(!is_readable($path)) return array(false,"文件\"{$path}\"不可读!");
    // 打开文件
    $fp=@fopen($path,"r");
    if (!$fp) {
        return array(false,"打开文件\"{$path}\"失败");
    }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);
        // 返回页数
        $page= array(true,$max);
        return $page[1];
    }
 set_time_limit(0);
      putenv('PATH=/www/wwwroot/print.jcdd315.com/public');
       shell_exec("/usr/bin/unoconv -f pdf  $filename 2>&1");

 

{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324203341&siteId=291194637