/    Sign up×
Community /Pin to ProfileBookmark

Word to HTML

I tried COM which helps to convert WORD DOC to HTML ..

is there anyway that i can convert WORD DOC to few numbers of HTML based on number of pages in word?

e.g.

a word doc with 2 pages …
when i convert it to html using COM .. 2 HTML will be created for each of the page from word.

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@bokehOct 27.2005 — You could use a REGEX to extract the body sections and then join them as one page.
Copy linkTweet thisAlerts:
@ltingauthorOct 27.2005 — REGEX to extract? ....... more details needed ... can you specify how? sorry i am noob ?
Copy linkTweet thisAlerts:
@bokehOct 27.2005 — [code=php]<?php

$page_one = '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
</head>
<body>
<p>Page One</p>
</body>
</html>';

$page_two = '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
</head>
<body>
<p>Page Two</p>
</body>
</html>';

preg_match('¥<body>(.*?)</body>¥is', $page_two, $matches);
$match = (isset($matches['1'])) ? $matches['1'] : FALSE;
$joined = preg_replace('¥(</body>)¥i', $match.'1', $page_one);

//view result
print '<pre>'.htmlspecialchars($joined).'</pre>';

?>[/code]
Copy linkTweet thisAlerts:
@ltingauthorOct 28.2005 — aik actually what i need ..

$word = new COM("word.application") or die("Unable to instanciate Word");

$docDir = getcwd();

//doc file location

$word->Documents->Open($docDir."rf.doc");

$temp = $word->Dialogs->Item(228);

$temp->Execute();

$numPages = $temp->Pages();

$word->Documents[1]->SaveAs($docDir."rf1.html",8);

//closing word

$word->Quit();




...........................................................

the code above help me to convert a word document to HTML ...

the word document consists of 4 pages ... how do i split the pages each to one html file?

now the convertion is done with 1 HTML consists of all 4 pages

any idea how?
Copy linkTweet thisAlerts:
@bokehOct 28.2005 — All you need to do is open the files you saved and join them using my method.
Copy linkTweet thisAlerts:
@ltingauthorOct 31.2005 — emmmm i want to split them actually ... not joining them ?

want to split the word doc to 4 HTML page ..
×

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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...