tags:

views:

344

answers:

3

Hi there,

I have a small web rich text editor that have some features like bolb, italic, and so on...

The text generated is html, and I would like to insert that text inside a word document bookmarks.

Putting the text into the bookmarks is not a problem. However, I have problems because of the text format (with the bolds for example).

Is there a fast way to "convert" text from html to doc, or just a way to include html into a word document?

This is an exemple:

 <p>Hello <strong>world<strong/></p>

This text should just appear "Hello World" in the word bookmark.

Thanks in advance.

A: 

Hi, nobody knows the answer? Thank you

A: 

Enclosing the html in ... <\body> tags should do the trick.

Tylor Durden
A: 

You just need to use Aspose.Words.

It will work something like this:

Document doc = new Document("mydoc.doc"); // Load your DOC, DOCX, RTF or WordML into memory.
DocumentBuilder builder = new DocumentBuilder(doc); // This is a "high-level" builder object that can help with a few things, such as inserting HTML.

builder.MoveToBookmark("myBookmark"); // Position the "cursor" where needed.

builder.InsertHtml(myHtmlString); // This will work nicely because Aspose.Words supports importing HTML.

doc.Save("mydoc out.doc"); // You can now save in any DOC, DOCX, RTF and more formats.
romeok