Fri Apr 05, 2024 4:18 am
public static string DocReader1(Stream stream)
{
//Create a Document object
FreeWord.Document doc = new FreeWord.Document();
//Load a Word document
stream.Position = 0;
doc.LoadFromStream(stream, FreeWord.FileFormat.Docx, FreeWord.Documents.XHTMLValidationType.None);
//Embed images in generated HTML file
doc.HtmlExportOptions.ImageEmbedded = true;
string htmlString = string.Empty;
//Save to HTML
using (MemoryStream ms = new MemoryStream())
{
doc.SaveToStream(ms, FreeWord.FileFormat.Html);
ms.Position = 0;
using (StreamReader reader = new StreamReader(ms, Encoding.UTF8))
{
htmlString = reader.ReadToEnd();
}
}
doc.Dispose();
return htmlString;
}
Login to view the files attached to this post.