This article describes how to open a previously loaded document for editing, which options should be applied, and how to send the document content to the WYSIWYG HTML-editor or any other editing application.
When a document is loaded into an instance of the Editor class, it is possible to open it for editing. In terms of GroupDocs.Editor, opening a document for editing implies creating an instance of the EditableDocument class by calling the Editor.edit() instance method. The edit() method can be called with a single parameter — an edit options instance — or without any parameter at all.
Each format family has its own edit options class. They are listed in the table below.
The parameterless edit() overload chooses the most appropriate default edit options based on the input document format.
The EditableDocument instance holds a version of the input document, converted to an internal intermediate format according to the 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.
fromgroupdocs.editorimportEditorfromgroupdocs.editor.optionsimportWordProcessingLoadOptions,WordProcessingEditOptionseditor=Editor("document.docx",WordProcessingLoadOptions())opened_document=editor.edit()# with default edit optionsedit_options=WordProcessingEditOptions()edit_options.enable_language_information=Trueedit_options.enable_pagination=Trueanother_opened_document=editor.edit(edit_options)
Several EditableDocument instances can be generated from a single Editor instance with different edit options. For example, for a WordProcessing document, the first time a user can call the edit() method with the paged mode disabled, and the second time with it enabled. In other words, several different EditableDocument representations of a single original document can be generated. Another example — there can be multiple EditableDocument instances for a single input Spreadsheet document, where each instance represents a different tab of the Spreadsheet document. Such an example is shown below.
fromgroupdocs.editorimportEditorfromgroupdocs.editor.optionsimportSpreadsheetLoadOptions,SpreadsheetEditOptionseditor=Editor("spreadsheet.xlsx",SpreadsheetLoadOptions())edit_options1=SpreadsheetEditOptions()edit_options1.worksheet_index=0# index is 0-based, so this is the 1st tabedit_options1.exclude_hidden_worksheets=Trueedit_options2=SpreadsheetEditOptions()edit_options2.worksheet_index=1# index is 0-based, so this is the 2nd tabedit_options2.exclude_hidden_worksheets=Falsefirst_tab=editor.edit(edit_options1)second_tab=editor.edit(edit_options2)
When the 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. This is briefly shown in the example below.