com.groupdocs.editor

Class InputHtmlDocument

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


    public final class InputHtmlDocument
    extends Object
    implements IAuxDisposable

    Encapsulates one HTML document, which is obtained from Document->HTML conversion and contains HTML markup and all related resources like CSS, images and fonts.


    The instances of this class are returned to the user during forward conversion (from document of any supported type to HTML). This class contains a set of useful methods and properties, which are required to "fill" the WYSIWYG HTML-editor.

    • Field Summary

      Fields 
      Modifier and Type Field and Description
      com.groupdocs.editor.events.ProcessEvents<com.groupdocs.editor.events.ProcessEventHandler> Disposed
      Event, which occurs when this HTML document is disposed, right after finishing the disposing process
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void dispose()
      Disposes this HTML document instance, disposing its content and making its methods and properties non-working
      String getBodyContent()
      Returns a body of the HTML document (content between opening and closing BODY tags without these tags) as a string.
      String getBodyContent(String externalResourcePrefix)
      Returns a body of the HTML document (content between opening and closing BODY tags without these tags) as a string, where links to the external resources contain specified prefix.
      String getContent()
      Returns overall content of the HTML document as a string.
      String getContent(String externalResourcePrefix)
      Returns overall content of the HTML document as a string, where links to the external resources contain specified prefix.
      List<CssText> getCss()
      Returns a list of CSS resources
      List<String> getCssContent()
      Returns content of all external stylesheets as a list of strings, where one string represents one stylesheet.
      List<String> getCssContent(String externalResourcePrefix)
      Returns content of all external stylesheets as a list of strings, where one string represents one stylesheet.
      String getEmbeddedHtml()
      Returns all content of this HTML document with all related resources in a form of a single string, where all resources are embedded inside the HTML markup in a base64-encoded form.
      List<FontResourceBase> getFontResources()
      Allows to obtain or specify external font resources, which are used by this HTML document
      List<IImageResource> getImageResources()
      Allows to obtain or specify external image resources (raster images), which are used by this HTML document
      boolean isDisposed()
      Determines whether this HTML document is already disposed or not
      void save(String htmlFilePath)
      Saves this HTML document to the file on specified path, where HTML markup will be stored, and to the accompanying folder with resources.
      void save(String htmlFilePath, boolean saveStylesheets)
      Saves this HTML document to the file on specified path, where HTML markup will be stored, and to the accompanying folder with resources.
      void save(String htmlFilePath, String resourcesFolderPath)
      Saves this HTML document to the file on specified path, where HTML markup will be stored, and to the accompanying folder with resources, which is located on specified path.
      void save(String htmlFilePath, String resourcesFolderPath, boolean saveStylesheets)
      Saves this HTML document to the file on specified path, where HTML markup will be stored, and to the accompanying folder with resources, which is located on specified path.
    • Field Detail

      • Disposed

        public final com.groupdocs.editor.events.ProcessEvents<com.groupdocs.editor.events.ProcessEventHandler> Disposed

        Event, which occurs when this HTML document is disposed, right after finishing the disposing process

    • Method Detail

      • dispose

        public void dispose()

        Disposes this HTML document instance, disposing its content and making its methods and properties non-working

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

        public String getBodyContent()

        Returns a body of the HTML document (content between opening and closing BODY tags without these tags) as a string.

        Returns:
        String, which contains the body of the HTML document


        WYSIWYG editors operate with the body of the document and cannot correctly process its meta information from the HEAD block. This method is designed for such cases.

      • getBodyContent

        public String getBodyContent(String externalResourcePrefix)

        Returns a body of the HTML document (content between opening and closing BODY tags without these tags) as a string, where links to the external resources contain specified prefix.

        Parameters:
        externalResourcePrefix - Through this parameter used can specify a prefix, which will be added to the links to all external resources (images, fonts, CSS), which will be present in the resultant HTML string. If NULL or empty, prefixes will not be added.


        WYSIWYG editors operate with the body of the document and cannot correctly process its meta information from the HEAD block. This method is designed for such cases.

        Returns:
        String, which contains the body of the HTML document with links, adjusted to the external resources
      • getContent

        public String getContent()

        Returns overall content of the HTML document as a string.

        Returns:
        String, which contains the content of the HTML document
      • getContent

        public String getContent(String externalResourcePrefix)

        Returns overall content of the HTML document as a string, where links to the external resources contain specified prefix.

        Parameters:
        externalResourcePrefix - Through this parameter used can specify a prefix, which will be added to the links to all external resources (images, fonts, CSS), which will be present in the resultant HTML string. If NULL or empty, prefixes will not be added.
        Returns:
        String, which contains the content of the HTML document with links, adjusted to the external resources
      • getCss

        public List<CssText> getCss()

        Returns a list of CSS resources

      • getCssContent

        public List<String> getCssContent()

        Returns content of all external stylesheets as a list of strings, where one string represents one stylesheet. Returns empty list, if there is no CSS for this document.

        Returns:
        A list of strings, where each string holds a content of one CSS document
      • getCssContent

        public List<String> getCssContent(String externalResourcePrefix)

        Returns content of all external stylesheets as a list of strings, where one string represents one stylesheet. Specified prefix will be applied to every link to the external resource in every resultant stylesheet. Returns empty list, if there is no CSS for this document.

        Parameters:
        externalResourcePrefix - Through this parameter used can specify a prefix, which will be added to the links to all external resources (images and fonts), which will be present in the resultant CSS strings. If NULL or empty, prefixes will not be added.
        Returns:
        A list of strings, where each string holds a content of one CSS document
      • getEmbeddedHtml

        public String getEmbeddedHtml()

        Returns all content of this HTML document with all related resources in a form of a single string, where all resources are embedded inside the HTML markup in a base64-encoded form.

        Returns:
        String, which is not NULL or empty in any case
      • getFontResources

        public List<FontResourceBase> getFontResources()

        Allows to obtain or specify external font resources, which are used by this HTML document

      • getImageResources

        public List<IImageResource> getImageResources()

        Allows to obtain or specify external image resources (raster images), which are used by this HTML document

      • isDisposed

        public boolean isDisposed()

        Determines whether this HTML document is already disposed or not

        Specified by:
        isDisposed in interface IAuxDisposable
      • save

        public void save(String htmlFilePath)

        Saves this HTML document to the file on specified path, where HTML markup will be stored, and to the accompanying folder with resources. It is allowed to disable saving of stylesheets.

        Parameters:
        htmlFilePath - Full path to the file, where HTML markup will be stored. File will be created or overwritten, if exists. Accompanying resource folder will be created in the same folder, where HTML file exist.
      • save

        public void save(String htmlFilePath,
                boolean saveStylesheets)

        Saves this HTML document to the file on specified path, where HTML markup will be stored, and to the accompanying folder with resources. It is allowed to disable saving of stylesheets.

        Parameters:
        htmlFilePath - Full path to the file, where HTML markup will be stored. File will be created or overwritten, if exists. Accompanying resource folder will be created in the same folder, where HTML file exist.
        saveStylesheets - Boolean flag, which determines whether it is required to save all external stylesheets to files or not
      • save

        public void save(String htmlFilePath,
                String resourcesFolderPath)

        Saves this HTML document to the file on specified path, where HTML markup will be stored, and to the accompanying folder with resources, which is located on specified path.

        Parameters:
        htmlFilePath - Full path to the file, where HTML markup will be stored. Cannot be NULL or empty. File will be created or overwritten, if exists.
        resourcesFolderPath - Full path to the accompanying folder, where all related resources will be stored. Cannot be NULL or empty. Folder will be created, if not exists.
      • save

        public void save(String htmlFilePath,
                String resourcesFolderPath,
                boolean saveStylesheets)

        Saves this HTML document to the file on specified path, where HTML markup will be stored, and to the accompanying folder with resources, which is located on specified path. It is allowed to disable saving of stylesheets.

        Parameters:
        htmlFilePath - Full path to the file, where HTML markup will be stored. Cannot be NULL or empty. File will be created or overwritten, if exists.
        resourcesFolderPath - Full path to the accompanying folder, where all related resources will be stored. Cannot be NULL or empty. Folder will be created, if not exists.
        saveStylesheets - Boolean flag, which determines whether it is required to save all external stylesheets to files or not