Srinivasa Rao D wrote: > Hi all, > * How better, i can read ms-word doc files from PHP on LINUX OS*.On > searching I got *catdoc* softaware.By using this i can read word doc data as > a text. > > function catdoc_file($fname) > { > > $ret = exec('catdoc -ab '.escapeshellarg($fname) .' 2>&1'); > > if (preg_match('/^sh: line 1: catdoc/i',$ret)) { > return false; > } > > return trim($ret); > } > It is working well. > > *Is there are any other softwares that can fetch text from MS-WORD file?.* > I wrote this routine a few months ago. $filename = './lflf.doc'; if ( file_exists($filename) ) { if ( ($fh = fopen($filename, 'r')) !== false ) { $headers = fread($fh, 0xA00); # 1 = (ord(n)*1) ; Document has from 0 to 255 characters $n1 = ( ord($headers[0x21C]) - 1 ); # 1 = ((ord(n)-8)*256) ; Document has from 256 to 63743 characters $n2 = ( ( ord($headers[0x21D]) - 8 ) * 256 ); # 1 = ((ord(n)*256)*256) ; Document has from 63744 to 16775423 characters $n3 = ( ( ord($headers[0x21E]) * 256 ) * 256 ); # 1 = (((ord(n)*256)*256)*256) ; Document has from 16775424 to 4294965504 characters $n4 = ( ( ( ord($headers[0x21F]) * 256 ) * 256 ) * 256 ); # Total length of text in the document $textLength = ($n1 + $n2 + $n3 + $n4); $extracted_plaintext = fread($fh, $textLength); # if you want the plain text with no formatting, do this echo $extracted_plaintext; # if you want to see your paragraphs in a web page, do this echo nl2br($extracted_plaintext); fclose($fh); } } This will grab the plain text out of a word document. Version 97' - 2003' It doesn't work for the newest OpenXML document format. -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php