Solved

doc2txt php script

Posted on 2008-10-02
1
1,362 Views
Last Modified: 2012-05-05
Hi,
could you provide me a php script that convert a doc document loaded in a variable ($document) to txt?
I don't need to maintain the format.

thanks
0
Comment
Question by:nokiamobile
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 5

Accepted Solution

by:
cammj earned 500 total points
ID: 22631489
It's not possible to directly read doc files if they were created using Microsoft Word, because the files are stored in a binary format that PHP cannot understand.

It is possible to leverage Microsoft Word to do the reading of the files though, but this requires that the OS you are running your php scripts on is a Windows machine and also has access to a copy of Microsoft Word.

This can be done with something like this

$filehandler = new COM("word.application");
$filehandler->Documents->Open(realpath("pathtomydocument.doc"));
$file = (string) $filehandler->ActiveDocument->Content;

echo $file;

$filehandler->ActiveDocument->Close(false);
$filehandler->Quit();
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question