I have a document docx
already saved in bytes[]
and I need to pass it to html so I can display it on a page.
I am using Visual Studio with .NET to develop it in C#.
Currently it works for me from pdf that is easy to transform to html but this is not the case with docx
any Microsoft product since I cannot use the native library interop
since it is not a guarantee that the server has it installed.
The end result is:
strFinalDoc = strFinalDoc.Replace("<body>", "<body>" + documentInfoHtml + "<BR /><BR />");
Where documentInfoHtml
is the result of transforming them bytes[]
to html and strFinalDoc
is simply the content that replaces that body
of a page.
I have found a solution but practically all interop
of them use either paid libraries.
Do you know any way to do it with free software or open projects?
Also I have to do the same process for files xls
and xlsx
.
The current answer is very good but it only covers one file doc
and not thedocx
It is also important to keep the existing CSS styles as much as possible, so answers that simply extract the content to generate it myself HTML
is not enough in the sense that it would lose all the formatting.