Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active September 19, 2019 06:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/ee2bd324e3a9bfc5b0c82f03b5d5eed1 to your computer and use it in GitHub Desktop.
Save GroupDocsGists/ee2bd324e3a9bfc5b0c82f03b5d5eed1 to your computer and use it in GitHub Desktop.
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.
sourceStream.Close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment