Greetings Happy New Year!

There is a need to open .doc files using php. How can this be done? It is desirable that the entire file structure is preserved (tables, enumerations, maybe even a font).

Thank you in advance.

ps. There are suggestions for how to open .docx

  • Googling, there is information about this. - Elime
  • Saw a couple of posts on Habré :) But there, as it is terribly written :) so maybe there is a way easier or maybe even embedded in php? ; D - BomBom

1 answer 1

If the method via the COM object suits you, here is an example.

$word = new COM("word.application") or die ("Could not initialise MS Word object."); // сообщение о ошибке если что-то не так $word->Documents->Open(realpath("Sample.doc")); // Получить содержимое $content = (string) $word->ActiveDocument->Content; echo $content; $word->ActiveDocument->Close(false); $word->Quit(); $word = null; unset($word); 
  • I'm not friends with English unfortunately. = ( - BomBom
  • Added to the question. - DUP