Last active
September 19, 2019 06:52
-
-
Save GroupDocsGists/ee2bd324e3a9bfc5b0c82f03b5d5eed1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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