Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edit .doc or .docx file using php

Tags:

php

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 file at run time. How is this possible anyone know please reply or give me example script.

Thanks,

like image 874
user343695 Avatar asked Jul 30 '10 06:07

user343695


People also ask

How can I edit a DOCX file in PHP?

You can use the PHPWord_Template Class to open an existing DOCX File and then replace some text marks with your individual text. Alternatively you can open the DOCX file with the ZipArchive extension and then read/write every xml File (document.

How do I open a DOCX file in PHP?

$filename = 'ahfdghasfdh. doc'; header('Content-type: application/msword'); header('Content-Disposition: inline; filename="testqq"'); @readfile($filename);

Can you edit Word DOCX?

We can edit DOCX file with an office application. As DOCX is very popular format there are a lot of office applications for different platforms like Windows, MacOSX, Linux etc.


2 Answers

I'm the developer of PHPWord. You can use the PHPWord_Template Class to open an existing DOCX File and then replace some text marks with your individual text.

Alternatively you can open the DOCX file with the ZipArchive extension and then read/write every xml File (document.xml, header.xml, footer.xml, ...) you want. This method is nothing else than the PHPWord_Template class. ;)

like image 172
Matthias Backhaus Avatar answered Oct 02 '22 17:10

Matthias Backhaus


You can use PHPWord.

like image 26
Shubham Avatar answered Oct 02 '22 15:10

Shubham