Thank you for your inquiry.
Please note that GroupDocs.Editor for .NET is a back-end, UI-independent API that could be easily integrated in any .NET application.
API can be used to edit the documents in HTML and then convert the edited document back into any supported document. It can also be used to generate output in different file formats using Html editor.
API supports input and output streams along with following features:
- Takes supported file format as input
- Edit document contents & styles in HTML format
- Convert Edited document into supported output format
We have API documentation and GitHub example projects (console and UI-Based) for your ease. We would recommend you to explore these resources.
As mentioned earlier, API is UI-Agnostic, you can devleop your own showcase/UI project as per your business needs or the uses case. GroupDocs.Editor for .NET can work with any front end UI that supports “WYSIWYG” HTML editor to edit the documents.
Hence, using following code you can extract HTML content of a document and then can manipulate it:
// Obtain document stream
System.IO.FileStream inputStream = System.IO.File.OpenRead(@"D:\Sample.docx");
using (InputHtmlDocument htmlDoc = EditorHandler.ToHtml(inputStream))
// Obtain HTML document content
string bodyContent = htmlDoc.GetContent();
Output document can be handled as follows:
string htmlContent = ""; // Initialize with HTML markup of the edited document
string resourcesFolderPath = ""; // Initialize with resources folder path
using (OutputHtmlDocument editedHtmlDoc = OutputHtmlDocument.FromMarkup(htmlContent, resourcesFolderPath))
string saveFilePath = ""; // Initialize with path to save edited document in original format
using (System.IO.FileStream outputStream = System.IO.File.Create(saveFilePath))
WordsSaveOptions saveOptions = new WordsSaveOptions();
saveOptions.OutputFormat = WordFormats.Rtf;
EditorHandler.ToDocument(editedHtmlDoc, outputStream, saveOptions);
Please note that GroupDocs.Editor cannot save an output document to a database, server file store or local file store by itself, because it knows nothing about end-user environment. This is a responsibility of the end-user. When you perform a direct conversion:
- Document of any type
- Edit and modify
- Save as HTML
Then resultant HTML is presented as InputHtmlDocument instance. If you need to obtain this HTML as a single byte stream, in order to save it somewhere, you can call a “GetEmbeddedHtml()” instance method.
It will return a single string object, which can be saved into the stream using standard .NET System.IO tools like System.IO.StreamWriter.