Save HTML to folder

This demonstration shows how to open input document, convert it to intermediate EditableDocument, and save to disk as HTML file with resource folder.

Almost all HTML WYSIWYG client-side editors are able to open HTML document from disk (from path). GroupDocs.Editor allows to open any supportable document, convert it to HTML and save to disk, which may be very useful for the subsequent editing it in some WYSIWYG editor. The code below demonstrates such example.

String inputFilePath = "C:\\input_path\\document.docx"; //path to some document
WordProcessingLoadOptions loadOptions = new WordProcessingLoadOptions();
Editor editor = new Editor(inputFilePath, loadOptions); //passing path and load options (via delegate) to the constructor
EditableDocument document = editor.edit(new WordProcessingEditOptions());
String outputHtmlFilePath = "C:\\output_path\\document.html"; //path to output HTML document
document.save(outputHtmlFilePath);

In this example we load input WordProcessing (DOCX) document to Editor class with load options, specific for this document family type - WordProcessingLoadOptions. Load options are passed via delegate. Then document is converted to the EditableDocument using the edit() method, which, in turn, obtains document-specific WordProcessingEditOptions. In the last line content is saved to the HTML file on disk, that is specified by absolute path. Please note that GroupDocs.Editor will create accompanying folder with resources automatically in the same directory, where HTML file is saved. There is another overload of the save() method, that obtains 2 parameters: path to HTML file and path to existing folder, where resources should be saved. For example, last 2 lines can be rewritten in the next way:

String outputHtmlFilePath = "C:\\output_path\\document.html"; //path to output HTML document
String outputHtmlFolderPath = "C:\\output_path\\document_files\\";//path to folder, where resources will be saved
document.save(outputHtmlFilePath, outputHtmlFolderPath);

By the way, don’t forget to dispose all resources, if you’re not using a using directive.

document.dispose();
editor.dispose();