473,397 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

MSWord -> Html

Hi,

Im making a html converter from word, and i have some difficulties in the
algorithm that parses the bolds, italics, and underlines...

if in a word document i have with some bolds, italic and underlined formats
(for instance, i have this paragraph) :

IM BOLD, IM UNDERLINED, IM ITALIC

i would like to convert to:

<b>IM BOLD,</B> <U>IM UNDERLINED,</U><I>IM ITALIC</I>

for me is easy to do:
<b>IM</b><b>BOLD</b><u>IM</u><u>UNDERLINED</u>.....
but following this way i have a lot of tags, and i would like to minimize
this...

If anybody knows how could i organize this algorithm (taking in count that
when a word is going to be parsed, i have to check what tags are open
before,etc...) i would be grateful...

--
Thanks a lot.
Regards.
Josema
Nov 17 '05 #1
3 1313
Josema,

The bold style you could reduce, but you can not reduce the underline
style. Having this:

<u>I'm</u> <u>underlined</u>

Is not the same as:

<u>I'm underlined</u>

That being said, you could look for words that are in bold, which are
separated by nothing but whitespace, and then wrap the bold tags around
that.

I think since Office XP, you can save word documents as HTML. Since you
are accessing the object model for word already to do this, why not just use
that facility instead?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Josema" <Je******@ocu.org> wrote in message
news:25**********************************@microsof t.com...
Hi,

Im making a html converter from word, and i have some difficulties in the
algorithm that parses the bolds, italics, and underlines...

if in a word document i have with some bolds, italic and underlined
formats
(for instance, i have this paragraph) :

IM BOLD, IM UNDERLINED, IM ITALIC

i would like to convert to:

<b>IM BOLD,</B> <U>IM UNDERLINED,</U><I>IM ITALIC</I>

for me is easy to do:
<b>IM</b><b>BOLD</b><u>IM</u><u>UNDERLINED</u>.....
but following this way i have a lot of tags, and i would like to minimize
this...

If anybody knows how could i organize this algorithm (taking in count that
when a word is going to be parsed, i have to check what tags are open
before,etc...) i would be grateful...

--
Thanks a lot.
Regards.
Josema

Nov 17 '05 #2
Hi Nicholas, first of all thanks for your fast and useful response...

Im accessing to the Office object model, cause Office 2000 when you use the
option save as html, a lot of code trash is created around...

--
Thanks again.
Regards.
Josema
"Nicholas Paldino [.NET/C# MVP]" wrote:
Josema,

The bold style you could reduce, but you can not reduce the underline
style. Having this:

<u>I'm</u> <u>underlined</u>

Is not the same as:

<u>I'm underlined</u>

That being said, you could look for words that are in bold, which are
separated by nothing but whitespace, and then wrap the bold tags around
that.

I think since Office XP, you can save word documents as HTML. Since you
are accessing the object model for word already to do this, why not just use
that facility instead?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Josema" <Je******@ocu.org> wrote in message
news:25**********************************@microsof t.com...
Hi,

Im making a html converter from word, and i have some difficulties in the
algorithm that parses the bolds, italics, and underlines...

if in a word document i have with some bolds, italic and underlined
formats
(for instance, i have this paragraph) :

IM BOLD, IM UNDERLINED, IM ITALIC

i would like to convert to:

<b>IM BOLD,</B> <U>IM UNDERLINED,</U><I>IM ITALIC</I>

for me is easy to do:
<b>IM</b><b>BOLD</b><u>IM</u><u>UNDERLINED</u>.....
but following this way i have a lot of tags, and i would like to minimize
this...

If anybody knows how could i organize this algorithm (taking in count that
when a word is going to be parsed, i have to check what tags are open
before,etc...) i would be grateful...

--
Thanks a lot.
Regards.
Josema


Nov 17 '05 #3
On Sat, 15 Oct 2005 06:53:01 -0700, Josema <Je******@ocu.org> wrote:
Hi,

Im making a html converter from word, and i have some difficulties in the
algorithm that parses the bolds, italics, and underlines...

if in a word document i have with some bolds, italic and underlined formats
(for instance, i have this paragraph) :

IM BOLD, IM UNDERLINED, IM ITALIC

i would like to convert to:

<b>IM BOLD,</B> <U>IM UNDERLINED,</U><I>IM ITALIC</I>

for me is easy to do:
<b>IM</b><b>BOLD</b><u>IM</u><u>UNDERLINED</u>.....
but following this way i have a lot of tags, and i would like to minimize
this...

If anybody knows how could i organize this algorithm (taking in count that
when a word is going to be parsed, i have to check what tags are open
before,etc...) i would be grateful...

Crude fix: replace "</b> <b>" with " ".

If you want to do it the proper way, then you are going to have a lot
of on/off switches. Some sort of bit array might be useful.

rossum


The ultimate truth is that there is no ultimate truth
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Eilsa | last post by:
I want to perform a full-text search for a lot of MSWord documents. So that I have to read the MSWord content and store it to the database. However, I cannot find any solution on it. What should I...
7
by: lkr | last post by:
hi is there is anyway to capture the document events of a MSWord?eg:I have to handle the event awhen WM_KEYUP or anyother events will occur. give me a solution............ thanks in advance lkr
1
by: Jason Huang | last post by:
Hi, I have no problem in creating or modifying a word document in ASP.Net, using C#. However, I don't know how to export database in SQL 2000 or MSAccess to MSWord, given in the ASP.Net and C#...
6
by: Peter | last post by:
I have to write a ASP.NET application that creates MSWord document from a template and populated with data from the webpage. (Templates can reside on the server or client's hard drive.) What is...
1
by: Matt Curreri | last post by:
I'm trying to automate the creation of a MSWord document with C#; however, when I start creating the MSWord document, I occassionly have a MSWord dialog box displaying a warning of low memory and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.