How to convert page HTML to word document. For example i have a web page which i need to save in word document. How to convert HTML Page to Word Document. And how to insert Page break in word document
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Below you can find an example to convert html to word.
It works fine and i had tested it on MS Office 2013 and Open Office.
Note : For page break insert below line
<br clear=all style='mso-special-character:line-break;page-break-before:always'>
Example:
Dim StrLocLetterText As StringBuilder = New StringBuilder()
Dim ObjLocHtml1 As String = "<html xmlns:v=""urn:schemas-microsoft-com:vml"" xmlns:o=""urn:schemas-microsoft-com:office:office"" xmlns:x=""urn:schemas-microsoft-com:office:word"" xmlns=""http://www.w3.org/TR/REC-html40""><head></head><body>"
Dim ObjLocHtml2 As String = "</body></html>"
StrLocLetterText.Append(ObjLocHtml1)
StrLocLetterText.Append(<Content within body tag>)
StrLocLetterText.Append(ObjLocHtml2)
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.Charset = ""
HttpContext.Current.Response.ContentType = "application/msword"
HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + <FileName> + ".doc")
HttpContext.Current.Response.Write(StrLocLetterText)
HttpContext.Current.Response.End()
HttpContext.Current.Response.Flush()
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0