Re: [PHP] ms-word reading from PHP on linux O.S

2009-04-04 Thread 9el
On Tue, Feb 24, 2009 at 1:38 PM, Per Jessen p...@computer.org wrote:

 Srinivasa Rao D wrote:

  Hi all,
* How better, i can  read ms-word doc files  from PHP on LINUX
OS*.
 [snip]
 
*Is there are any other softwares that can fetch text from MS-WORD
file?.*


Word documents reading using COM in PHP have a look
http://drewd.com/2007/01/25/reading-from-a-word-document-with-com-in-php

Lenin
www.twitter.com/nine_L


Re: [PHP] ms-word reading from PHP on linux O.S

2009-04-04 Thread Phpster



On Apr 4, 2009, at 15:19, 9el le...@phpxperts.net wrote:


On Tue, Feb 24, 2009 at 1:38 PM, Per Jessen p...@computer.org wrote:


Srinivasa Rao D wrote:


Hi all,
 * How better, i can  read ms-word doc files  from PHP on LINUX
 OS*.

[snip]


 *Is there are any other softwares that can fetch text from MS-WORD
 file?.*




Word documents reading using COM in PHP have a look
http://drewd.com/2007/01/25/reading-from-a-word-document-with-com-in-php

Lenin
www.twitter.com/nine_L


COM doesn't work on linux. Try using open office if available. What do  
you need to do with the doc file?


Bastien

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] ms-word reading from PHP on linux O.S

2009-02-23 Thread Bob McConnell
From: Srinivasa Rao D
 
  * 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.

It would be helpful to have a little more context. What do you want to
do with the text you read this way?

When I run across a MS-Word document, my browser is configured to
download it to disk. Then I open it with OpenOffice.write and extract
what I need.

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ms-word reading from PHP on linux O.S

2009-02-23 Thread Jim Lucas
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) .' 21');
 
 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



Re: [PHP] ms-word reading from PHP on linux O.S

2009-02-23 Thread Srinivasa Rao D
thanks Lucas.This code is very helpful to me.


Re: [PHP] ms-word reading from PHP on linux O.S

2009-02-23 Thread Per Jessen
Srinivasa Rao D wrote:

 Hi all,
   * How better, i can  read ms-word doc files  from PHP on LINUX
   OS*.
[snip]
 
   *Is there are any other softwares that can fetch text from MS-WORD
   file?.*

OpenOffice.



-- 
Per Jessen, Zürich (1.9°C)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php