com.aspose.html

Class HTMLDocument

    • Constructor Detail

      • HTMLDocument

        public HTMLDocument()

        Initializes a new instance of the HTMLDocument class.

      • HTMLDocument

        public HTMLDocument(Configuration configuration)

        Initializes a new instance of the HTMLDocument class.

        Parameters:
        configuration - The environment configuration.
      • HTMLDocument

        public HTMLDocument(Url url)

        Initializes a new instance of the HTMLDocument class. Constructor works synchronously, it waits for loading of all the external resources (images, scripts, etc.). To load document asynchronously use method Document.navigate(Url) or its overloads. Or you can disable loading of some external resources by setting appropriate flags in IBrowsingContext.Security(IBrowsingContext.getSecurity()).

        Parameters:
        url - The document URL.
      • HTMLDocument

        public HTMLDocument(Url url,
                            Configuration configuration)

        Initializes a new instance of the HTMLDocument class. Constructor works synchronously, it waits for loading of all the external resources (images, scripts, etc.). To load document asynchronously use method Document.navigate(Url) or its overloads. Or you can disable loading of some external resources by setting appropriate flags in IBrowsingContext.Security(IBrowsingContext.getSecurity()).

        Parameters:
        url - The document URL.
        configuration - The environment configuration.
      • HTMLDocument

        public HTMLDocument(String address)

        Initializes a new instance of the HTMLDocument class. Constructor works synchronously, it waits for loading of all the external resources (images, scripts, etc.). To load document asynchronously use method Document.navigate(String) or its overloads. Or you can disable loading of some external resources by setting appropriate flags in IBrowsingContext.Security(IBrowsingContext.getSecurity()).

        Parameters:
        address - The document address.
      • HTMLDocument

        public HTMLDocument(String address,
                            Configuration configuration)

        Initializes a new instance of the HTMLDocument class. Constructor works synchronously, it waits for loading of all the external resources (images, scripts, etc.). To load document asynchronously use method Document.navigate(String) or its overloads. Or you can disable loading of some external resources by setting appropriate flags in IBrowsingContext.Security(IBrowsingContext.getSecurity()).

        Parameters:
        address - The document address.
        configuration - The environment configuration.
      • HTMLDocument

        public HTMLDocument(String content,
                            String baseUri)

        Initializes a new instance of the HTMLDocument class. Constructor works synchronously, it waits for loading of all the external resources (images, scripts, etc.). To load document asynchronously use method Document.navigate(String, String) or its overloads. Or you can disable loading of some external resources by setting appropriate flags in IBrowsingContext.Security(IBrowsingContext.getSecurity()).

        Parameters:
        content - The document content.
        baseUri - The base URI of the document.
        Throws:
        com.aspose.ms.System.ArgumentNullException - baseUri is null.
      • HTMLDocument

        public HTMLDocument(String content,
                            String baseUri,
                            Configuration configuration)

        Initializes a new instance of the HTMLDocument class. Constructor works synchronously, it waits for loading of all the external resources (images, scripts, etc.). To load document asynchronously use method Document.navigate(String, String) or its overloads. Or you can disable loading of some external resources by setting appropriate flags in IBrowsingContext.Security(IBrowsingContext.getSecurity()).

        Parameters:
        content - The document content.
        baseUri - The base URI of the document.
        configuration - The environment configuration.
        Throws:
        com.aspose.ms.System.ArgumentNullException - baseUri is null.
      • HTMLDocument

        public HTMLDocument(InputStream content,
                            String baseUri)

        Initializes a new instance of the HTMLDocument class.

        Parameters:
        content - The document content.
        baseUri - The base URI of the document.
      • HTMLDocument

        public HTMLDocument(com.aspose.ms.System.IO.Stream content,
                            String baseUri)

        Initializes a new instance of the HTMLDocument class. Constructor works synchronously, it waits for loading of all the external resources (images, scripts, etc.). To load document asynchronously use method Document.navigate(Stream, String) or its overloads. Or you can disable loading of some external resources by setting appropriate flags in IBrowsingContext.Security(IBrowsingContext.getSecurity()).

        Parameters:
        content - The document content.
        baseUri - The base URI of the document.
        Throws:
        com.aspose.ms.System.ArgumentNullException - baseUri is null.
      • HTMLDocument

        public HTMLDocument(InputStream content,
                            String baseUri,
                            Configuration configuration)

        Initializes a new instance of the HTMLDocument class.

        Parameters:
        content - The document content.
        baseUri - The base URI of the document.
        configuration - The environment configuration.
      • HTMLDocument

        public HTMLDocument(com.aspose.ms.System.IO.Stream content,
                            String baseUri,
                            Configuration configuration)

        Initializes a new instance of the HTMLDocument class. Constructor works synchronously, it waits for loading of all the external resources (images, scripts, etc.). To load document asynchronously use method Document.navigate(Stream, String) or its overloads. Or you can disable loading of some external resources by setting appropriate flags in IBrowsingContext.Security(IBrowsingContext.getSecurity()).

        Parameters:
        content - The document content.
        baseUri - The base URI of the document.
        configuration - The environment configuration.
        Throws:
        com.aspose.ms.System.ArgumentNullException - baseUri is null.
      • HTMLDocument

        public HTMLDocument(RequestMessage request)

        Initializes a new instance of the HTMLDocument class. Constructor works synchronously, it waits for loading of all the external resources (images, scripts, etc.). To load document asynchronously use method Document.navigate(RequestMessage) or its overloads. Or you can disable loading of some external resources by setting appropriate flags in IBrowsingContext.Security(IBrowsingContext.getSecurity()).

        Parameters:
        request - The request message.
      • HTMLDocument

        public HTMLDocument(RequestMessage request,
                            Configuration configuration)

        Initializes a new instance of the HTMLDocument class. Constructor works synchronously, it waits for loading of all the external resources (images, scripts, etc.). To load document asynchronously use method Document.navigate(RequestMessage) or its overloads. Or you can disable loading of some external resources by setting appropriate flags in IBrowsingContext.Security(IBrowsingContext.getSecurity()).

        Parameters:
        request - The request message.
        configuration - The environment configuration.
      • HTMLDocument

        public HTMLDocument(com.aspose.html.BrowsingContext context)

        Initializes a new instance of the HTMLDocument class.

        Parameters:
        context - The context.
    • Method Detail

      • getTitle

        @DOMNameAttribute(name="title")
        public String getTitle()

        The title of a document as specified by the TITLE element in the head of the document.

      • setTitle

        @DOMNameAttribute(name="title")
        public void setTitle(String value)

        The title of a document as specified by the TITLE element in the head of the document.

      • getBody

        @DOMNameAttribute(name="body")
        public HTMLElement getBody()

        The element that contains the content for the document. In documents with BODY contents, returns the BODY element. In frameset documents, this returns the outermost FRAMESET element.

      • setBody

        @DOMNameAttribute(name="body")
        public void setBody(HTMLElement value)

        The element that contains the content for the document. In documents with BODY contents, returns the BODY element. In frameset documents, this returns the outermost FRAMESET element.

      • getApplets

        @DOMNameAttribute(name="applets")
        public HTMLCollection getApplets()

        A collection of all the OBJECT elements that include applets and APPLET (deprecated) elements in a document.

      • getLinks

        @DOMNameAttribute(name="links")
        public HTMLCollection getLinks()

        A collection of all AREA elements and anchor ( A) elements in a document with a value for the href attribute.

      • getCookie

        @DOMNameAttribute(name="cookie")
        public String getCookie()

        This mutable string attribute denotes persistent state information that (1) is associated with the current frame or document and (2) is composed of information described by the cookies non-terminal of [<a href="http://www.ietf.org/rfc/rfc2965.txt">IETF RFC 2965</a>], Section 4.2.2. If no persistent state information is available for the current frame or document document, then this property's value is an empty string. When this attribute is read, all cookies are returned as a single string, with each cookie's name-value pair concatenated into a list of name-value pairs, each list item being separated by a ';' (semicolon). When this attribute is set, the value it is set to should be a string that adheres to the cookie non-terminal of [<a href="http://www.ietf.org/rfc/rfc2965.txt">IETF RFC 2965</a>]; that is, it should be a single name-value pair followed by zero or more cookie attribute values. If no domain attribute is specified, then the domain attribute for the new value defaults to the host portion of an absolute URI [<a href="http://www.ietf.org/rfc/rfc2396.txt">IETF RFC 2396</a>] of the current frame or document. If no path attribute is specified, then the path attribute for the new value defaults to the absolute path portion of the URI [<a href="http://www.ietf.org/rfc/rfc2396.txt">IETF RFC 2396</a>] of the current frame or document. If no max-age attribute is specified, then the max-age attribute for the new value defaults to a user agent defined value. If a cookie with the specified name is already associated with the current frame or document, then the new value as well as the new attributes replace the old value and attributes. If a max-age attribute of 0 is specified for the new value, then any existing cookies of the specified name are removed from the cookie storage. See [<a href="http://www.ietf.org/rfc/rfc2965.txt">IETF RFC 2965</a>] for the semantics of persistent state item attribute value pairs. The precise nature of a user agent session is not defined by this specification.

        Value: The cookie.
      • setCookie

        @DOMNameAttribute(name="cookie")
        public void setCookie(String value)

        This mutable string attribute denotes persistent state information that (1) is associated with the current frame or document and (2) is composed of information described by the cookies non-terminal of [<a href="http://www.ietf.org/rfc/rfc2965.txt">IETF RFC 2965</a>], Section 4.2.2. If no persistent state information is available for the current frame or document document, then this property's value is an empty string. When this attribute is read, all cookies are returned as a single string, with each cookie's name-value pair concatenated into a list of name-value pairs, each list item being separated by a ';' (semicolon). When this attribute is set, the value it is set to should be a string that adheres to the cookie non-terminal of [<a href="http://www.ietf.org/rfc/rfc2965.txt">IETF RFC 2965</a>]; that is, it should be a single name-value pair followed by zero or more cookie attribute values. If no domain attribute is specified, then the domain attribute for the new value defaults to the host portion of an absolute URI [<a href="http://www.ietf.org/rfc/rfc2396.txt">IETF RFC 2396</a>] of the current frame or document. If no path attribute is specified, then the path attribute for the new value defaults to the absolute path portion of the URI [<a href="http://www.ietf.org/rfc/rfc2396.txt">IETF RFC 2396</a>] of the current frame or document. If no max-age attribute is specified, then the max-age attribute for the new value defaults to a user agent defined value. If a cookie with the specified name is already associated with the current frame or document, then the new value as well as the new attributes replace the old value and attributes. If a max-age attribute of 0 is specified for the new value, then any existing cookies of the specified name are removed from the cookie storage. See [<a href="http://www.ietf.org/rfc/rfc2965.txt">IETF RFC 2965</a>] for the semantics of persistent state item attribute value pairs. The precise nature of a user agent session is not defined by this specification.

        Value: The cookie.
      • getOverrideStyle

        public ICSSStyleDeclaration getOverrideStyle(Element elt,
                                                     String pseudoElt)

        This method is used to retrieve the override style declaration for a specified element and a specified pseudo-element.

        Specified by:
        getOverrideStyle in interface IDocumentCSS
        Parameters:
        elt - The element whose style is to be modified. This parameter cannot be null.
        pseudoElt - The pseudo-element or null if none.
        Returns:
        The override style declaration
      • save

        public void save(Url url)

        Saves the document to local file specified by url. All resources used in this document will be saved in to adjacent folder, whose name will be constructed as: output_file_name + "_files".

        Parameters:
        url - Local URL to output file.
        Throws:
        com.aspose.ms.System.ArgumentException - Raised if the specified url is not a valid local file URL.
      • save

        public void save(String path)

        Saves the document to local file specified by path. All resources used in this document will be saved in to adjacent folder, whose name will be constructed as: output_file_name + "_files".

        Parameters:
        path - Local path to output file.
        Throws:
        com.aspose.ms.System.ArgumentException - Raised if the specified path is not a valid local file path.
      • save

        public void save(String path,
                         int saveFormat)

        Saves the document to local file specified by path. All resources used in this document will be saved in to adjacent folder, whose name will be constructed as: output_file_name + "_files".

        Parameters:
        path - Local path to output file.
        saveFormat - Format in which document is saved.
        Throws:
        com.aspose.ms.System.ArgumentException - Raised if the specified path is not a valid local file path.
      • save

        public void save(Url url,
                         int saveFormat)

        Saves the document to local file specified by url. All resources used in this document will be saved in to adjacent folder, whose name will be constructed as: output_file_name + "_files".

        Parameters:
        url - Local URL to output file.
        saveFormat - Format in which document is saved.
        Throws:
        com.aspose.ms.System.ArgumentException - Raised if the specified url is not a valid local file URL.
      • save

        public void save(String path,
                         HTMLSaveOptions saveOptions)

        Saves the document to local file specified by path. All resources used in this document will be saved in to adjacent folder, whose name will be constructed as: output_file_name + "_files".

        Parameters:
        path - Local path to output file.
        saveOptions - HTML save options.
        Throws:
        com.aspose.ms.System.ArgumentException - Raised if the specified path is not a valid local file path.
      • save

        public void save(Url url,
                         HTMLSaveOptions saveOptions)

        Saves the document to local file specified by url. All resources used in this document will be saved in to adjacent folder, whose name will be constructed as: output_file_name + "_files".

        Parameters:
        url - Local URL to output file.
        saveOptions - HTML save options.
        Throws:
        com.aspose.ms.System.ArgumentException - Raised if the specified url is not a valid local file URL.
      • save

        public void save(String path,
                         MarkdownSaveOptions saveOptions)

        Saves the document to local file specified by path. All resources used in this document will be saved in to adjacent folder, whose name will be constructed as: output_file_name + "_files".

        Parameters:
        path - Local path to output file.
        saveOptions - Markdown save options.
        Throws:
        com.aspose.ms.System.ArgumentException - Raised if the specified path is not a valid local file path.
      • save

        public void save(Url url,
                         MarkdownSaveOptions saveOptions)

        Saves the document to local file specified by url. All resources used in this document will be saved in to adjacent folder, whose name will be constructed as: output_file_name + "_files".

        Parameters:
        url - Local URL to output file.
        saveOptions - Markdown save options.
        Throws:
        com.aspose.ms.System.ArgumentException - Raised if the specified url is not a valid local file URL.
      • save

        public void save(String path,
                         MHTMLSaveOptions saveOptions)

        Saves the document to local file specified by path. All resources used in this document will be saved in to adjacent folder, whose name will be constructed as: output_file_name + "_files".

        Parameters:
        path - Local path to output file.
        saveOptions - MHTML save options.
        Throws:
        com.aspose.ms.System.ArgumentException - Raised if the specified path is not a valid local file path.
      • save

        public void save(Url url,
                         MHTMLSaveOptions saveOptions)

        Saves the document to local file specified by url. All resources used in this document will be saved in to adjacent folder, whose name will be constructed as: output_file_name + "_files".

        Parameters:
        url - Local URL to output file.
        saveOptions - MHTML save options.
        Throws:
        com.aspose.ms.System.ArgumentException - Raised if the specified url is not a valid local file URL.
      • renderTo

        public void renderTo(IDevice device)

        This method is used to print the contents of the current document to the specified device.

        Overrides:
        renderTo in class Document
        Parameters:
        device - The user device.