How do I retain Embedded Style of Inserted HTML in .Net Word

I want to insert the content of an html file into a word doc and I like the word doc to retain the format/style of the original html file.

I used the following 2 sets of codes

1

Dim doc As Document = New Document(Server.MapPath("~/test.htm"))

For Each section As Section In doc.Sections

Dim ps As PageSetup = section.PageSetup

ps.Orientation = Orientation.Landscape

Next

doc.UpdatePageLayout()

doc.Save(Server.MapPath("~/output1.doc"), SaveFormat.Doc)

2

Dim htmlString As String = " ....."

builder.InsertHtml(htmlString)

For Each section As Section In doc.Sections

Dim ps As PageSetup = section.PageSetup

ps.Orientation = Orientation.Landscape

Next

doc.UpdatePageLayout()

doc.Save(Server.MapPath("~/output2.doc"), SaveFormat.Doc)

The final documents(output1.doc & output2.doc) did not keep the original format/style of the html. But when I opened the original html file (test.htm) in a web browser, copied and pasted the content onto a new MS Word document, the original format/style was retained.

Could you please advise on how I can insert content of the html file in a word doc and still maintain in the word doc, the embedded styles of the original html.

Thank you in advance.

Hello,


Thanks for your inquiry. Can you please provide us the HTML file and the HTML String so that we can investigate it on our side. Technically Aspose.Word has to render your HTML properly.

We appreciate your co-operation in this regard.

Best Regards,

Amir Ghias

Hi Amir,

Many thanks for your quick response.

Please find attached file.

Hi
Abidemi,


Thanks for your inquiry. Please note that it is not guaranteed that the output Word document will look exactly the same as the input HTML. This is because Aspose.Words was originally designed to work with MS Word documents, and HTML documents are quite different. That is why some HTML features are not supported upon importing HTML and some features are not supported upon exporting HTML. You can find limitations upon HTML exporting/importing here:

http://www.aspose.com/docs/display/wordsnet/Load+in+the+HTML+%28.HTML%2C+.XHTML%2C+.MHTML%29+Format
http://www.aspose.com/docs/display/wordsnet/Save+in+the+HTML+%28.HTML%2C+.XHTML%2C+.MHTML%29+Format

Please let me know if I can be of any further assistance.

Best Regards,