This article describes how to open for editing a previously loaded document, which options should be applied, and how to send document content to the WYSIWYG HTML-editor or any other editing application.
When document is loaded into the instance of the Editor class, it is possible to open it for editing. In terms of GroupDocs.Editor, open a document for edit implies creating an instance of EditableDocument class by calling an Editor.Edit() instance method. There are two overloads of the Edit method. First one obtains a single parameter — inheritor of IEditOptions interface. Each format family has its own implementation of IEditOptions interface. They are listed in the table below.
Second overload is parameterless — it chooses the most appropriate default edit options based on input document format.
EditableDocument instance holds a version of input document, converted to internal intermediate format according to edit options. When it is ready, it can emit HTML, CSS and other appropriate content, that can be passed directly to the WYSIWYG-editor. This is demonstrated below.
stringinputFilePath="C:\\input_path\\document.docx";//path to some documentEditoreditor=newEditor(inputFilePath,delegate{returnnewWordProcessingLoadOptions();});EditableDocumentopenedDocument=editor.Edit();//with default edit optionsWordProcessingEditOptionseditOptions=newWordProcessingEditOptions();editOptions.EnableLanguageInformation=true;editOptions.EnablePagination=true;EditableDocumentanotherOpenedDocument=editor.Edit(editOptions);
There can be generated several EditableDocument instances from a single Editor instance with different edit options. For example, for WordProcessing document, first time user can call Edit() method with disabled paged mode, and for the second time — with enabled. In other words, there can be generated several different EditableDocument representations of the single original document. Other example — there can be multiple EditableDocument instances for a single input Spreadsheet document, where each instance represents different tab of the Spreadsheet document. Such example is shown below.
stringinputXlsxPath="C://input/spreadsheet.xlsx";Editoreditor=newEditor(inputXlsxPath,delegate{returnnewSpreadsheetLoadOptions();});SpreadsheetEditOptionseditOptions1=newSpreadsheetEditOptions();editOptions1.WorksheetIndex=0;//index is 0-based, so this is 1st tabeditOptions1.ExcludeHiddenWorksheets=true;SpreadsheetEditOptionseditOptions2=newSpreadsheetEditOptions();editOptions2.WorksheetIndex=1;//index is 0-based, so this is 2nd tabeditOptions2.ExcludeHiddenWorksheets=false;EditableDocumentfirstTab=editor.Edit(editOptions1);EditableDocumentsecondTab=editor.Edit(editOptions2);
When EditableDocument instance is ready, it can emit HTML-markup, CSS-markup and other resources in different forms for passing them to the client-side WYSIWYG HTML-editor or any other application, that can edit HTML documents. It is briefly shown in the example below.