0

I want to count the number of pages of .doc file. I have used ZipArchive() but its works only for .docx and also used linux command

"vSummary sample.doc | grep -oP '(?<=of Pages = )[ A-Za-z0-9]*'

but its also not works. Can anyone give mw to solution for get page count for .doc file in PHP.

$zip = new ZipArchive();
if($zip->open($file) === true) {
    if(($index = $zip->locateName('docProps/app.xml')) !== false)
    {
        $data = $zip->getFromIndex($index);
        $zip->close();

        $xml = new SimpleXMLElement($data);
        print_r($xml);
        $pageCount= $xml->Pages;
    }
 
    $zip->close();
}

And also used of linux command :

wvSummary sample.doc | grep -oP '(?<=of Pages = )[ A-Za-z0-9]*'

But not working

Reegan Miranda
  • 2,879
  • 6
  • 43
  • 55
  • 1
    _I have used_ Please post your codes. You cant expect the community to write the entire function for you. – endeavour Jun 30 '21 at 05:56
  • Hello @user3251758, you might want to take a look into: https://stackoverflow.com/help/minimal-reproducible-example – Tomáš Filip Jun 30 '21 at 06:06
  • @endeavour with zip archive function : $zip = new ZipArchive(); if($zip->open($file) === true) { // echo "vvvvv"; if(($index = $zip->locateName('docProps/app.xml')) !== false) { $data = $zip->getFromIndex($index); $zip->close(); $xml = new SimpleXMLElement($data); print_r($xml); $pageCount= $xml->Pages; } echo "
    ";
            print_r($xml);
            $zip->close();
    }
    – user3251758 Jun 30 '21 at 06:25
  • Please edit your question with proper syntax. The questions use markdown to format a piece of text. When you post there should be a help section that tells you how to format common parts – endeavour Jun 30 '21 at 06:35
  • 1
    Refer to this question for an answer https://stackoverflow.com/questions/40826396/how-to-get-the-no-of-pages-from-doc-file-in-php-the-following-code-works-for – endeavour Jun 30 '21 at 06:37

0 Answers0