Page 1 of 1

Conversion from Word to HTML

Posted: Wed Apr 20, 2005 7:53 am
by vivekjain
Hi,
I am building an application in PHP, wherein I am asking the user to upload a word document. Once he does that, I want to display that word doc in HTML format, how do i do that, without using 3rd party tools?

thanks

Posted: Wed Apr 20, 2005 7:59 am
by feyd
use COM to start Word, and save out the file as an html file. Be careful when doing this though..

Although if the server isn't a Windows machine with Word installed, you need a third party tool then.

Posted: Wed Apr 20, 2005 8:04 am
by Trenchant
if your actually openning user submited files then your going to need a lot of security. By opening a simple 6 kb exe file you could totally fry your harddrive.

Makesure you check all extensions your processing.

Posted: Wed Apr 20, 2005 8:05 am
by malcolmboston
isnt microsoft word the worst program in the world for generating HTML?

Conversion from Word to HTML

Posted: Wed Apr 20, 2005 8:24 am
by vivekjain
I am trying to do that, but I get this error:

Warning: (null)(): Unable to lookup Documents: Error accessing the OLE registry. in c:\inetpub\wwwroot\StrAppWorks\testpages\WordToHTML\wth.php on line 4

the code that I am using:

Code: Select all

<?
$word = new COM("word.application") or die("Unable to instanciate Word");
$word->Visible = 1;
$word->Documents->Open("one.doc");
$word->Documents[1]->SaveAs("test_one.html",1);
$word->Quit();
$word->Release();
$word = null;
?>

feyd | Please review how to post code using

Code: Select all

and

Code: Select all

tags. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]