com.groupdocs.editor

Class Editor

  • All Implemented Interfaces:
    com.aspose.ms.System.IDisposable, IAuxDisposable


    public final class Editor
    extends Object
    implements IAuxDisposable

    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'.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      com.aspose.ms.lang.Event<com.aspose.ms.System.EventHandler> Disposed 
    • Constructor Summary

      Constructors 
      Constructor and Description
      Editor(InputStream document)
      Initializes new Editor instance with specified input document (as a stream)
      Editor(InputStream document, ILoadOptions loadOptions)
      Initializes new Editor instance with specified input document (as a stream) with its load options
      Editor(InputStream document, ILoadOptions loadOptions, com.groupdocs.editor.EditorSettings settings)
      Initializes new Editor instance with specified input document (as a stream) with its load options and Editor settings
      Editor(String filePath)
      Initializes new Editor instance with specified input document (as a full file path)
      Editor(String filePath, ILoadOptions loadOptions)
      Initializes new Editor instance with specified input document (as a full file path) with its load options
      Editor(String filePath, ILoadOptions loadOptions, com.groupdocs.editor.EditorSettings settings)
      Initializes new Editor instance with specified input document (as a full file path) with its load options and Editor settings
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void dispose()
      Disposes this instance of Editor, so that it releases all internal resources and becomes unavailable for further usage
      EditableDocument 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.
      EditableDocument edit(IEditOptions editOptions)
      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.
      IDocumentInfo getDocumentInfo(String password)
      Returns metadata about the document, that was loaded to this 'Editor' instance
      boolean isDisposed()
      Indicates whether this Editor instance was already disposed and cannot be used anymore (true) or not and is active (false)
      void save(EditableDocument inputDocument, OutputStream outputDocument, ISaveOptions saveOptions)
      Converts specified edited document, represented as instance of 'EditableDocument', to the resultant document of specified format and saves its content to specified stream
      void save(EditableDocument inputDocument, String filePath, ISaveOptions saveOptions)
      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
    • Field Detail

      • Disposed

        public final com.aspose.ms.lang.Event<com.aspose.ms.System.EventHandler> Disposed
    • Constructor Detail

      • Editor

        public Editor(InputStream document)

        Initializes new Editor instance with specified input document (as a stream)

        Parameters:
        document - Delegate, that should return a stream with document content. Should not be NULL.
      • Editor

        public Editor(InputStream document,
              ILoadOptions loadOptions)

        Initializes new Editor instance with specified input document (as a stream) with its load options

        Parameters:
        document - Delegate, that should return a stream with document content. Should not be NULL.
        loadOptions - Delegate, that should return a document load options. May be NULL and may return null - in that case document type will be detected automatically and default load options for that type will be applied.
      • Editor

        public Editor(InputStream document,
              ILoadOptions loadOptions,
              com.groupdocs.editor.EditorSettings settings)

        Initializes new Editor instance with specified input document (as a stream) with its load options and Editor settings

        Parameters:
        document - Delegate, that should return a stream with document content. Should not be NULL.
        loadOptions - Delegate, that should return a document load options. May be NULL and may return null - in that case document type will be detected automatically and default load options for that type will be applied.
        settings - Delegate, that returns Editor settings, which allow to set custom logger or caching. May be NULL - in that case Editor will use own settings.
      • Editor

        public Editor(String filePath)

        Initializes new Editor instance with specified input document (as a full file path)

        Parameters:
        filePath - Full path to the file. Should not be NULL. Should be valid, and file should exist.
      • Editor

        public Editor(String filePath,
              ILoadOptions loadOptions)

        Initializes new Editor instance with specified input document (as a full file path) with its load options

        Parameters:
        filePath - Full path to the file. Should not be NULL. Should be valid, and file should exist.
        loadOptions - Delegate, that should return a document load options. May be NULL and may return null - in that case document type will be detected automatically and default load options for that type will be applied.
      • Editor

        public Editor(String filePath,
              ILoadOptions loadOptions,
              com.groupdocs.editor.EditorSettings settings)

        Initializes new Editor instance with specified input document (as a full file path) with its load options and Editor settings

        Parameters:
        filePath - Full path to the file. Should not be NULL. Should be valid, and file should exist.
        loadOptions - Delegate, that should return a document load options. May be NULL and may return null - in that case document type will be detected automatically and default load options for that type will be applied.
        settings - Delegate, that returns Editor settings, which allow to set custom logger or caching. May be NULL - in that case Editor will use own settings.
    • Method Detail

      • dispose

        public final void dispose()

        Disposes this instance of Editor, so that it releases all internal resources and becomes unavailable for further usage

        Specified by:
        dispose in interface com.aspose.ms.System.IDisposable
      • edit

        public final EditableDocument 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.

        Returns:
        Instance of the 'EditableDocument' class, which encapsulates overall input document with all its resources in intermediate format. This method, if successfully finished, never returns NULL.


        When input original document is loaded to the 'Editor' instance through the constructor, this method allows to open document for editing by converting it to intermediate format, which is encapsulated within instance of 'EditableDocument' class. 'EditableDocument', returned from this method, contains all necessary methods and properties for producing HTML markup and corresponding resources (like images, fonts and stylesheets) in all necessary configurations for subsequent passing them into any WYSIWYG HTML-editor. This overload applies edit options, which are default for the format, to which the input document belongs.
      • edit

        public final EditableDocument edit(IEditOptions editOptions)

        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.

        Parameters:
        editOptions - Format-specific document options, which allows to tune-up conversion process. Should not be NULL. Should not conflict with previously applied load options.


        When input original document is loaded to the 'Editor' instance through the constructor, this method allows to open document for editing by converting it to intermediate format, which is encapsulated within instance of 'EditableDocument' class. 'EditableDocument', returned from this method, contains all necessary methods and properties for producing HTML markup and corresponding resources (like images, fonts and stylesheets) in all necessary configurations for subsequent passing them into any WYSIWYG HTML-editor. This overload obtains edit options, which are specific for family formats.
        Returns:
        Instance of the 'EditableDocument' class, which encapsulates overall input document with all its resources in intermediate format. This method, if successfully finished, never returns NULL.
      • getDocumentInfo

        public final IDocumentInfo getDocumentInfo(String password)

        Returns metadata about the document, that was loaded to this 'Editor' instance

        Parameters:
        password - User can specify a password for a document, if this document is encrypted with the password. May be NULL or empty string, that is equivalent to the absent password.


        GetDocumentInfo method is useful when it is unclear of which type is the input document, is it password-protected and/or how many pages/worksheets/slides it contains. Based on this metadata, returned by GetDocumentInfo, it is possible to correctly adjust the load and edit options for the main processing pipeline. GetDocumentInfo method always returns full data, it is not affected by the trial mode, its usage doesn't write off consumed bytes or credits.
        Returns:
        Format-specific inheritor of IDocumentInfo interface, that indicates detected format with format-specific metadata, or NULL, if document was not recognized as supportable.
      • isDisposed

        public final boolean isDisposed()

        Indicates whether this Editor instance was already disposed and cannot be used anymore (true) or not and is active (false)

        Specified by:
        isDisposed in interface IAuxDisposable
      • save

        public final void save(EditableDocument inputDocument,
                OutputStream outputDocument,
                ISaveOptions saveOptions)

        Converts specified edited document, represented as instance of 'EditableDocument', to the resultant document of specified format and saves its content to specified stream

        Parameters:
        inputDocument - Version of the input document, that was edited in WYSIWYG HTML-editor and is stored as instance of 'EditableDocument' class, which should be converted to output document of some specific format
        outputDocument - Output stream, in which the content of the resultant document will be recorded. Should not be NULL, disposed, should support writing.
        saveOptions - Document saving options, which define the format of the resultant document, and also general and format-specific saving options.
      • save

        public final void save(EditableDocument inputDocument,
                String filePath,
                ISaveOptions saveOptions)

        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

        Parameters:
        inputDocument - Version of the input document, that was edited in WYSIWYG HTML-editor and is stored as instance of 'EditableDocument' class, which should be converted to output document of some specific format
        filePath - Path to the file, in which the output document will be saved. It file with the same name exists, it will be completely rewritten.
        saveOptions - Document saving options, which define the format of the resultant document, and also general and format-specific saving options.