Conversion from Word to HTML

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vivekjain
Forum Commoner
Posts: 76
Joined: Thu Jan 08, 2004 12:38 am

Conversion from Word to HTML

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
Trenchant
Forum Contributor
Posts: 291
Joined: Mon Nov 29, 2004 6:04 pm
Location: Web Dummy IS

Post 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.
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

isnt microsoft word the worst program in the world for generating HTML?
vivekjain
Forum Commoner
Posts: 76
Joined: Thu Jan 08, 2004 12:38 am

Conversion from Word to HTML

Post 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]
Post Reply