Jump to content

Trying to read content of a document in PHP


aldrin151

Recommended Posts

Anyone know how to open a different application beside MS word, or excel for example in PHP to be able to read text content...I have tried the below code and works trying to open and read a word .doc file and then close word in the background...my only problem is that I'm trying to use a UNIX or Linux server and not a Windows to make this work...any solutions will be greatly appreciated!  Thanks  :)

 

<?php

$word = new COM("word.application") or die ("Could not initialise MS Word object.");

$word->Documents->Open(realpath("test.doc"));

 

// Extract content.

$content = (string) $word->ActiveDocument->Content;

 

echo $content;

 

$word->ActiveDocument->Close(false);

 

$word->Quit();

$word = null;

unset($word);

 

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.