Extracting text from Word Documents via PHP and COM


/ Published in: PHP
Save to your folder(s)

Requires an insecure, I mean Windows server (doh!)


Copy this code and paste it in your HTML
  1. $word = new COM("word.application") or die ("Could not initialise MS Word object.");
  2. $word->Documents->Open(realpath("Sample.doc"));
  3. // Extract content.
  4. $content = (string) $word->ActiveDocument->Content;
  5. echo $content;
  6. $word->ActiveDocument->Close(false);
  7. $word->Quit();
  8. $word = null;
  9. unset($word);

URL: http://www.developertutorials.com/blog/php/extracting-text-from-word-documents-via-php-and-com-81/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.