I'm trying to convert a .rtf file to a .doc or .docx file, in PHP. But I wonder if this is even possible in PHP. Does anybody know if this even possible?
Asked
Active
Viewed 1,920 times
2 Answers
1
You can use OpenOffice or LibreOffice to do it, from command line:
soffice --headless --convert-to <TargetFileExtension>:<NameOfFilter> file_to_convert.xxx
or using a C++ library that can be used from PHP, called PUNO: http://www.wstech2.net/index.php?do=0a,01,05

Ademir Mazer Jr - Nuno
- 890
- 18
- 30
-
Unfortunately I can't install software on the server – Ruub Aug 11 '14 at 12:13
0
Have a search for PHP Word libraries:
PHPWord is a good place to start, same people that develop PHPExcel.

iswinky
- 1,951
- 3
- 16
- 47
-
PHPWord helped me converting my .doc file to docx. That worked perfectly. But it doesn't look like it can convert a .rtf to .doc or .docx. It does work the other way, you can convert a .doc to .rtf, but that's not what I want :) Or did I miss something? – Ruub Aug 11 '14 at 12:01
-
Can't you just add the strings from the .rtf to the word document and output the file? Rather than straight conversion – iswinky Aug 11 '14 at 12:02
-
-
1@Ruub You say "PHPWord helped me converting my .doc file to docx." How did you do that? All my research says that PHPWord doesn't support the `.doc` format, only the `.docx` format (see http://stackoverflow.com/questions/7358637). – Val Kornea Dec 17 '14 at 19:59