PHP Get height and width in Pdf file proprieties

后端 未结 4 1057
孤街浪徒
孤街浪徒 2020-12-06 08:06

I have a PDF file. I would to get it height and width in mm.

So I do an exec(pdfinfo ... ); I have this result :

Creator: Adobe InDesign CS5 (

4条回答
  •  青春惊慌失措
    2020-12-06 08:42

    Why not use plain PHP to get the pdf dimensions?

    eof()) {
            if (preg_match("/".$box."\[[0-9]{1,}.[0-9]{1,} [0-9]{1,}.[0-9]{1,} ([0-9]{1,}.[0-9]{1,}) ([0-9]{1,}.[0-9]{1,})\]/", $stream->fgets(), $matches)) {
                $result["width"] = $matches[1];
                $result["height"] = $matches[2]; 
                break;
            }
        }
    
        $stream = null;
    
        return $result;
    }
    
    var_dump(get_pdf_dimensions("file.pdf"));
    

提交回复
热议问题