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 document
Editoreditor=newEditor(inputFilePath,newWordProcessingLoadOptions());EditableDocumentopenedDocument=editor.edit();//with default edit options
WordProcessingEditOptionseditOptions=newWordProcessingEditOptions();editOptions.setEnableLanguageInformation(true);editOptions.setEnablePagination(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,newSpreadsheetLoadOptions());SpreadsheetEditOptionseditOptions1=newSpreadsheetEditOptions();editOptions1.setWorksheetIndex(0);//index is 0-based, so this is 1st tab
editOptions1.setExcludeHiddenWorksheets(true);SpreadsheetEditOptionseditOptions2=newSpreadsheetEditOptions();editOptions2.setWorksheetIndex(1);//index is 0-based, so this is 2nd tab
editOptions2.setExcludeHiddenWorksheets(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.