Main Content

mlreportgen.dom.HTMLPage Class

Namespace: mlreportgen.dom

Create a single HTML page of a multipage HTML document

Since R2024a

Description

Create a single HTML page within a multipage HTML document. Add any Document Object Model (DOM) API content object, such as Text, Paragraph, Image, Table, to an HTMLPage object.

Note

You can add an HTMLPage object only to a DOM document of type html-multipage.

The mlreportgen.dom.HTMLPage class is a handle class.

Class Attributes

HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

example

htmlPageObj = mlreportgen.dom.HTMLPage creates an empty HTMLPage object that generates an HTML file. By default, the filename is the Document name appended with the page number, except for the first page, which is root.html. Use its append method to add content to the HTML page. When added to a DOM Document of type html-multipage, the API generates an HTML file, which corresponds to a single page of the multipage HTML report.

htmlPageObj = mlreportgen.dom.HTMLPage(fileName) also specifies the fileName.

htmlPageObj = mlreportgen.dom.HTMLPage(fileName,templatePath) also specifies the custom template templatePath.

htmlPageObj = mlreportgen.dom.HTMLPage(fileName,domObj) also specifies domObj as the page content.

Properties

expand all

Name of the generated HTML file, specified as a character vector or a string scalar. If you do not specify this property, the function takes the filename of the DOM Document object and appends the page number of the HTML page. For example, if the multipage HTML Document name is myreport, the second page of the report is myreport_2.html. The first page in the report always has the name root.html.

If the file name does not specify an extension, .html is used as the extension for the generated HTML file. If the file name specifies an extension, it must be .html. If any extension other than .html is specified, an error is thrown.

Example: "myreport.html"

Attributes:

NonCopyable
true

Data Types: char | string

Path of page template, specified as a character vector or string scalar. By default, this property specifies the path of the default multipage HTML template default_multipage.htmtx, whose body contains three holes:

  • "NavBarTop" specifies the navigation bar at the top of the page.

  • "Content" specifies the page content.

  • "NavBarBottom" specifies the navigation bar at the bottom of the page.

Attributes:

NonCopyable
true

Data Types: char | string

Parent of mlreportgen.dom.HTMLPage object, specified as a document element object. A document element must have only one parent.

Attributes:

SetAccess
private
NonCopyable
true

Children of mlreportgen.dom.HTMLPage object, specified as an array of document element objects. This property contains the document element objects appended using the append method.

Attributes:

SetAccess
private
NonCopyable
true

Tag for mlreportgen.dom.HTMLPage object, specified as a character vector or string scalar. The DOM API generates a session-unique tag as part of the creation of this object. The generated tag has the form CLASS:ID, where CLASS is the object class and ID is the value of the Id property of the object. Specify your own tag value to help you identify where to look when an issue occurs during document generation.

Attributes:

NonCopyable
true

Data Types: char | string

Object identifier for mlreportgen.dom.HTMLPage object, specified as a character vector or string scalar. The DOM API generates a session-unique identifier when it creates the document element object. You can specify your own value for Id.

Attributes:

NonCopyable
true

Data Types: char | string

Methods

expand all

Examples

collapse all

Create a multipage HTML report.

Import the DOM API package so that you do not have to use fully qualified class names.

import mlreportgen.dom.*

Create a multipage HTML document.

d = Document("myreport","html-multipage");
open(d);

Create the first HTML page with an image.

page1 = HTMLPage;
append(page1,Heading1("Chapter 1. Image"));
img = Image(which("ngc6543a.jpg"));
img.Height = "4in";
img.Width = "4in";
append(page1,img);
append(d,page1);

Create the second HTML page with a table.

page2 = HTMLPage;
append(page2,Heading1("Chapter 2. Table"));
tbl = Table(magic(5));
tbl.Border = "solid";
tbl.RowSep = "solid";
tbl.ColSep = "solid";
tbl.Width = "100%";
append(page2,tbl);
append(d,page2);

Create the third HTML page with a nested list.

page3 = HTMLPage();
append(page3,Heading1("Chapter 3. List"));
append(page3,UnorderedList({"a", "b", "c", {1,2,3}, "d"}));
append(d,page3);

Close and view the report.

close(d);
rptview(d);

Version History

Introduced in R2024a

See Also