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.