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.
stringinputFilePath="C:\\input_path\\document.docx";//path to some documentWordProcessingLoadOptionsloadOptions=newWordProcessingLoadOptions();Editoreditor=newEditor(inputFilePath,delegate{returnloadOptions;});//passing path and load options (via delegate) to the constructorEditableDocumentdocument=editor.Edit(newWordProcessingEditOptions());stringoutputHtmlFilePath="C:\\output_path\\document.html";//path to output HTML documentdocument.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:
stringoutputHtmlFilePath="C:\\output_path\\document.html";//path to output HTML documentstringoutputHtmlFolderPath="C:\\output_path\\document_files\\";//path to folder, where resources will be saveddocument.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();
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.