Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
string documentPath = @"C:\sample.docx";
// Obtain document stream
Stream sourceStream = File.Open(documentPath, FileMode.Open, FileAccess.Read);
using (InputHtmlDocument htmlDoc = EditorHandler.ToHtml(sourceStream))
// Obtain HTML document content
string htmlContent = htmlDoc.GetContent();
// Edit html in WYSIWYG-editor...
// Save edited html to original document format
using (OutputHtmlDocument editedHtmlDoc = OutputHtmlDocument.FromMarkup(htmlContent, Path.Combine(Common.sourcePath, Common.resultResourcesFolder)))
using (System.IO.FileStream outputStream = System.IO.File.Create(@"C:\output\edited.docx"))
WordProcessingSaveOptions saveOptions = new WordProcessingSaveOptions();
EditorHandler.ToDocument(editedHtmlDoc, outputStream, saveOptions);
// close stream object to release file for other methods.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment