0

I want to parse .doc files or convert it to HTML or txt files when user upload it. i found this link ( http://instruform.com/wordconv.phps) but it is not working. Can anybody suggest some php script for the same.(need urgently). please give some suggestion....

Thanks in advance

10
Contributors
11
Replies
41
Views
9 Years
Discussion Span
Last Post by pritaeas
Featured Replies
  • 1
    pritaeas 1,949   1 Year Ago

    This forum is not a problem solving service. If you have problems coding this, post what you have, clearly explain your issue and you will get help. Read More

0

this could help you

<?php

// htmlviewer.php
// convert a Word doc to an HTML file

//$DocumentPath = str_replace("\\", "\", $DocumentPath);
$DocumentPath="C:/Archivos de programa/Easyphp/www/subidas/curric.doc";

// create an instance of the Word application
$word = new COM("word.application") or die("Unable to instantiate application object");

// creating an instance of the Word Document object
$wordDocument = new COM("word.document") or die("Unable to instantiate document object");
$word->Visible = 0;
// open up an empty document
$wordDocument = $word->Documents->Open($DocumentPath);

// create the filename for the HTML version
$HTMLPath = substr_replace($DocumentPath, 'txt', -3, 3);

// save the document as HTML
$wordDocument->SaveAs($HTMLPath, 3);

// clean up
$wordDocument = null;
$word->Quit();
$word = null;

// redirect the browser to the newly-created document header("Location:". $HTMLPath);

header("Location:". $HTMLPath);
?>
0

It's good script but I need do something like that WITHOUT USE COM objects. Site with this script is hosting by Linux provier

0

Hi friends,

I am new in php and same problem i am facing in conversion.
I want to convert .doc/.docx/.rtf file to .txt or .html format.
i am using linux server so preferably can't choose COM component.
Can any one help me out. ITs urgent.

thanks in advance.

Edited by bhmb2000: n/a

0

This comes up on a fairly regular basis and I don't think that anyone has identified a really good solution. There are one or two (PHP) programs that attempt to convert from Doc to text but they aren't 100% accurate. It can be done with COM but that doesn't help you on Linux. You could do it as a local program (with COM) rather than as a server-based program. In that case you would do the conversion and the upload from the user end. This is very "do-able" but has the obvious inconvenience for the user of having to download the program. A program like that could be done quite easily using Autoit.

Other ways at it could be:
* Convert it to PDF (using the Zend conversion tool) and store / display that.
* Have the user upload something other than a .doc file (e.g. RTF) that you may be able to interpret more easily. You could also have them save from Word into html directly but the output is a terrible jumble that you wouldn't want to deal with.
* Possibly try to incorporate Open Office components that might be able to do this.
* Just leave it as a Doc file and save / display that.

1

wow...
just got the solution.
see the link http://www.wagner.pp.ru/~vitus/software/catdoc/
If you are a Linux/Ubuntu user then
1]just download the catdoc-0.94.2.tar.gz file. Extract it.
2]Go to terminal and go to extracted directory.
3]run commands
./configure
make
sudo make install
(Hope that it will get instlled!!!)
4]if installation is successful then try command man catdoc.
(It should give you manual of catdoc)
5]Now just do
catdoc <file_name.doc>
6] If want its output in another text file the
catdoc <file_name.doc> > xyz.txt

Hope it works.
because it worked for me.
Please let me know if am wrong.

0

@Priti_P

That is very good alternative solution, who only needs to read "textual" data.

Thanks!

-2

We have several pdf/doc files/ We need to convert them into html pages. Kindly write a php code for it. You need to get a third party library for it.

Input -

  1. a doc file(we will do it for pdfs later on)
  2. directory path where html page should be saved
  3. name of html page

Output - a html page with given name in the given directory
plzz solve my problam

1

This forum is not a problem solving service.

If you have problems coding this, post what you have, clearly explain your issue and you will get help.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.