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
You may easily run the code above and see the feature in action in our GitHub examples:
- GroupDocs.Editor for .NET examples, plugins, and showcase
- GroupDocs.Editor for Java examples, plugins, and showcase
- Document Editor for .NET MVC UI Example
- Document Editor for .NET App WebForms UI Modern Example
- Document Editor for Java App Dropwizard UI Modern Example
- Document Editor for Java Spring UI Example
Free Online App
Along with full-featured Java library we provide simple but powerful free Apps.
You are welcome to edit your Microsoft Word (DOC, DOCX, RTF etc.), Microsoft Excel (XLS, XLSX, CSV etc.), Open Document (ODT, OTT, ODS) and other documents with free to use online GroupDocs Editor App.