Edit .doc or .docx file using php

后端 未结 5 1453
攒了一身酷
攒了一身酷 2021-02-07 14:24

I have to modify the uploaded .doc or .docx file in php. I googled but i only found how to read that. I want the word file as it is and put text at the bottom of that MS Word fi

5条回答
  •  粉色の甜心
    2021-02-07 14:46

    I have same requirement for Edit .doc or .docx file using php and i have find solution for it. And i have write post on It :: http://www.onlinecode.org/update-docx-file-using-php/

    if($zip_val->open($full_path) == true)
    {
        // In the Open XML Wordprocessing format content is stored.
        // In the document.xml file located in the word directory.
    
        $key_file_name = 'word/document.xml';
        $message = $zip_val->getFromName($key_file_name);               
    
        $timestamp = date('d-M-Y H:i:s');
    
        // this data Replace the placeholders with actual values
        $message = str_replace("client_full_name",      "onlinecode org",       $message);
        $message = str_replace("client_email_address",  "ingo@onlinecode.org",  $message);
        $message = str_replace("date_today",            $timestamp,         $message);      
        $message = str_replace("client_website",        "www.onlinecode.org",   $message);      
        $message = str_replace("client_mobile_number",  "+1999999999",          $message);
    
        //Replace the content with the new content created above.
        $zip_val->addFromString($key_file_name, $message);
        $zip_val->close();
    }
    

提交回复
热议问题