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
You only replace the predefined variables. In the following code
https://github.com/PHPOffice/PHPWord I also did this problem in phpword using the following code
if(!file_exists('file/word.docx')){
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('demo.docx');
$templateProcessor->setValue('name', 'Akbarali');
$templateProcessor->setValue('time','13.02.2021');
$templateProcessor->setValue('month', 'January');
$templateProcessor->setValue('state','Uzbekistan');
$templateProcessor->saveAs('file/word.docx');
}
This will change the words in the demo.docx file. The new file is then saved in the word.docx file folder. you can define variables in the form of $ {name} in the demo word file. that is, ${name}, ${time}, ${month} and ${state}