0

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?

Alexis Pigeon
  • 7,423
  • 11
  • 39
  • 44
Ruub
  • 619
  • 1
  • 13
  • 41

2 Answers2

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

0

Have a search for PHP Word libraries:

http://phpword.codeplex.com/

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
  • Hmm yeah I think I can try that – Ruub Aug 11 '14 at 12:16
  • 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