Page 1 of 1
Read word and output as HTML
Posted: Fri Sep 19, 2003 4:06 am
by JayBird
Im looking to read word files and diplay the info as HTML.
Not really sure where to begin.
I've hard COM mentioned a lot, but haven't got a clue about that at all.
Any pointers?
Thanks
Mark
Posted: Fri Sep 19, 2003 4:39 am
by Nay
word files? You mean like myfile.doc - a Microsoft Word file.
-Nay
Posted: Fri Sep 19, 2003 4:47 am
by JayBird
yup, thats exactly what i mean
Mark
Posted: Fri Sep 19, 2003 5:11 am
by m3mn0n
goooogle ownz j00 & also
this
Posted: Fri Sep 19, 2003 5:36 am
by JayBird
okay, i got a script.
Code: Select all
<?
// starting word
$word = new COM("word.application") or die("Unable to instanciate Word");
// if you want see thw World interface the value must be '1' else '0'
$word->Visible = 0;
//doc file location
$word->Documents->Open("c:\\first.doc");
//html file location '8' mean HTML format
$word->Documents[1]->SaveAs("c:\\test_doc.html",8);
//closing word
$word->Quit();
//free the object from the memory
$word->Release();
$word = null;
?>
But, do i need to change anything in my PHP to allow the use of COM?
Can't see anything in the manual.
The script above when run, just sits there in the browser and nerver ends and never outputs anything?
Mark
Posted: Fri Sep 19, 2003 5:53 am
by volka
you should try it as console-application first. Maybe there's a popup and the task is never finished. I remember when I did this in a c++-class there were some unexpected message boxes, e.g. a confirmation request because of losing some formatting informations when saving as html. And there was a property to be set to avoid the UI-elements.
Posted: Fri Sep 19, 2003 6:01 am
by JayBird
console-application? How would i do that?
Mark
Posted: Fri Sep 19, 2003 6:18 am
by volka
just run the script from a dos box, e.g.
Code: Select all
d:\path\to\php.exe -f e:\path\to\script.php
Posted: Fri Sep 19, 2003 6:28 am
by JayBird
when i run it from the command line, it works perfectly!?
So why not in the broswer?
Mark
Posted: Fri Sep 19, 2003 7:49 am
by volka
-- caution: wild guessing follows --
remember the
nag screen when you started ms office/word for the first time? That one where you should enter your name, your initials and whatever. The webserver probably handles the request with another account than the one that has been
configured. So maybe it's trying to show that screen again for the
new user, after all the usual word.exe is started for the word.application object. By default a win32-service is not allowed to display UI elements on the desktop, i.e. if it uses the "local system" account.
It
would fit the behaviour you've descripted. But I've banned ms office completely from my box (no I'm not a no-m$ stickler, simply no need for it

) so I can't test it.
From the services-applet you can open the property sheet of the webserver. If it's configured to use "local system" you might try the checkbox right below that setting, allowing the service to access the default desktop.
But as mentioned: it's a long shot.
Posted: Fri Sep 19, 2003 8:18 am
by JayBird
what is the services-applet? Im on win98 with apache.
Is there definately no setting in the php.ini that enables diasbles COM?
THanks
Mark
Posted: Fri Sep 19, 2003 8:21 am
by JayBird
There are these settings, nut i have no idea what they do
com.allow_dcom "0" PHP_INI_SYSTEM
com.autoregister_typelib "0" PHP_INI_SYSTEM
com.autoregister_verbose "0" PHP_INI_SYSTEM
com.autoregister_casesensitive "1" PHP_INI_SYSTEM
com.typelib_file "" PHP_INI_SYSTEM
Mark
Posted: Fri Sep 19, 2003 8:32 am
by JayBird
found this on the PHP manual
It should be noted that to run anything that needs to interact with the UI (the word example), one needs to ensure that the process that the Web server is running under can access the UI. For Apache, this is an option in the Services control panel.
Apparently i need to start -> run and type dcomcnfg but that is only for NT/2K/XP.
I am on win98. How can i allow PHP to access the UI?
Mark