Hi All
I am reading an word document by using the following code
<?php
$filename = "C:/wamp/www/OpenID.doc";
$word = new COM("word.application") or die("Unable to instantiate Word");
$word->Documents->Open($filename);
$new_filename = substr($filename,0,-4) . ".txt";
// the '2' parameter specifies saving in txt format
$word->Documents[1]->SaveAs($new_filename,2);
$word->Documents[1]->Close(false);
$word->Quit();
//$word->Release();
$word = NULL;
unset($word);
$fh = fopen($new_filename, 'r');
// this is where we exit Hell
$contents = fread($fh, filesize($new_filename));
fclose($fh);
unlink($new_filename);
echo("<pre>$contents</pre>");
?>
But then it prints the $contents on the browser then the word formatting are missing , can anybody suggest me how to maintain the formatting of the document. And it should be displayed on browser as it is in the word document.










Bookmarks