Editor

Editor class

Main class, which encapsulates conversion methods. Editor class provides methods for loading, editing, and saving documents of all supportable formats. It is disposable, so use a ‘using’ directive or dispose its resources manually via ‘Dispose()’ method call. Document loading is performed through constructors. Document editing - through method ‘Edit’, and saving back to the resultant document after edit - through method ‘Save’.

public sealed class Editor : IAuxDisposable

Constructors

Name Description
Editor(Func<Stream>) Initializes new Editor instance with specified input document (as a stream)
Editor(string) Initializes new Editor instance with specified input document (as a full file path)
Editor(Action<Stream>, IDocumentFormat) Initializes a new instance of the Editor class and creates a new empty document based on the specified format.
Editor(Func<Stream>, Func<ILoadOptions>) Initializes new Editor instance with specified input document (as a stream) with its load options
Editor(string, Func<ILoadOptions>) Initializes new Editor instance with specified input document (as a full file path) with its load options

Properties

Name Description
IsDisposed { get; } Indicates whether this Editor instance was already disposed and cannot be used anymore (true) or it was not disposed yet and thus is active (false)

Methods

Name Description
Dispose() Disposes this instance of Editor, so that it releases all internal resources and becomes unavailable for further usage
Edit() Opens a previously loaded document for editing using default options by generating and returning an instance of ‘EditableDocument’ class, that, in turn, contains methods for producing HTML markup and associated resources.
Edit(IEditOptions) Opens a previously loaded document for editing using specified format-specific options by generating and returning an instance of ‘EditableDocument’ class, that, in turn, contains methods for producing HTML markup and associated resources.
GetDocumentInfo(string) Returns metadata about the document, that was loaded to this ‘Editor’ instance
Save(EditableDocument, Stream, ISaveOptions) Converts specified edited document, represented as instance of ‘EditableDocument’, to the resultant document of specified format and saves its content to specified stream
Save(EditableDocument, string, ISaveOptions) Converts specified edited document, represented as instance of ‘EditableDocument’, to the resultant document of specified format and saves its content to file by specified file path

Events

Name Description
event Disposed Event, which occurs when this Editor instance is disposed with all its internal resources

Remarks

Editor class should be considered as an entry point and the root object of the GroupDocs.Editor. All operations are performed using this class. Typical usage of the Editor class for performing a full document editing pipeline is the next:

  1. Load a document into the Editor instance through its constructor.
  2. Optionally, detect a document type using a GetDocumentInfo method.
  3. Open a document for editing by calling an Edit method and obtaining an instance of EditableDocument class from it.
  4. Editing a document content on client-side using any WYSIWYG HTML-editor.
  5. Creating a new instance of EditableDocument from edited document content.
  6. Saving an edited document to some output format by calling a Save method.
  7. Disposing an instance of Editor class via ‘using’ operator or manually.

See Also