Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

doc2txt php script

Posted on 2008-10-02
1
Medium Priority
?
1,404 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 1500 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

722 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