/    Sign up×
Community /Pin to ProfileBookmark

Words to HTML

i am doing a convertion script to convert word docs to HTML ..
but i got a little bit problem here, perhaps someone can help me on this ..

$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 = 1;

$docDir = getcwd();
//doc file location
$word->Documents->Open($docDir.”rf.doc”);

//html file location ‘8’ mean HTML format
$word->Documents[1]->SaveAs($docDir.”rf.html”,8);

//closing word
$word->Quit();

//free the object from the memory
$word->Release();
$word = null;

above is my script for the convertion … it helps to convert particular word docs to HTML format … if works fine if i want to convert the entire doc to HTML but what if i only want the 2nd page inside that word doc to be converted to HTML … anyone pls?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@SpectreReturnsNov 15.2005 — Perhaps search for the pagebreak and then substring to wherever you want to end?
Copy linkTweet thisAlerts:
@ltingauthorNov 15.2005 — emmm any idea how to search for the page break ...

and after i get the page break how do i save the 2nd page into HTML!

pls help me T_T
Copy linkTweet thisAlerts:
@purefanNov 15.2005 — You should check http://cr.php.net/variant and there [b]richard dot quadling at carval dot co dot uk[/b]'s comment which I think is what you are looking for

also maybe this link here helps:

http://www.microsoft.com/downloads/details.aspx?FamilyID=209ADBEE-3FBD-482C-83B0-96FB79B74DED&displaylang=EN

and reading other forum I found:
[code=php]
<?
$word=new COM("word.application") or die("Cannot start word for you");
print "Loaded word version ($word->Version)n";
$word->visible =1;
$word->Documents->Add();
$word->Selection->Typetext("Dit is een test");
$word->Documents[1]->SaveAs("burb ofzo.doc");
$word->Quit();
?> [/code]


and also:

all you have to do is make sure you set the content type properly:

header('Content-Type: application/msword');

readfile('file.doc');

Chris

ps. If application/msword doesn't work, try application/octet-stream.

pps. For a full list of mime types, the mime.types file in your apache

configuration.

> -----Original Message-----

> From: pgsql-php-owner ( at ) postgresql ( dot ) org

> [mailto:pgsql-php-owner ( at ) postgresql ( dot ) org]On Behalf Of Kris-Jon Fenton

> Sent: Wednesday, 13 February 2002 9:50 AM

> To: pgsql-php ( at ) postgresql ( dot ) org

> Subject: [code=php] Viewing Word Documents using PHP
>
>
> Hi,
>
> I am trying to view Word Docs on our intranet.
>
> All I can get is a load of code.
>
> Someone suggested that I use wvHtml - www.wvware.com - to convert
> the files
> but I am not sure how to tell PHP to use it??
>
> I have used readfile but still junk!
>
> Thanks
> Kris
>
[/quote]
×

Success!

Help @lting spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...