Main Content

mlreportgen.dom.Heading1 Class

Namespace: mlreportgen.dom
Superclasses: mlreportgen.dom.Heading

Create Heading1 paragraph

Description

Use an object of the mlreportgen.dom.Heading1 class to create an mlreportgen.dom.Heading1 paragraph object.

To see what DOM objects you can append an mlreportgen.dom.Heading1 object to, see Append mlreportgen.dom.Heading1 object to DOM class object.

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

Creation

Description

headingObj = Heading1 creates an empty Heading1 object.

headingObj = Heading1(text) creates the heading containing the specified text.

example

headingObj = Heading1(text,styleName) creates the heading using the specified style.

headingObj = Heading1(domObj) creates the heading containing the specified DOM object.

Input Arguments

expand all

Text to use for the heading, specified as a character vector or string scalar.

Data Types: char | string

The style specified by styleName must specify a paragraph style defined in the template used to create the document to which this heading is appended.

Data Types: char | string

Properties

expand all

Background color, specified as a character vector or string scalar that contains a CSS color name, hexadecimal RGB value, or decimal RGB value.

FormatValue
CSS color nameSpecify a CSS color name. For a list of CSS color names, see https://www.w3.org/wiki/CSS/Properties/color/keywords.
Hexadecimal RGB valueUse the format "#RRGGBB". Use # as the first character and two-digit hexadecimal numbers for the red, green, and blue values. You can use uppercase or lowercase letters.
Decimal RGB color valueUse the format "rgb(r,g,b)", where r, g, and b are comma-separated positive integers that specify the red, green, and blue values, respectively. Each value range must be between 0 and 255.

Setting the BackgroundColor property adds a mlreportgen.dom.BackgroundColor format object to the Style property. Setting the BackgroundColor property to an empty value removes the object.

Example: "red" specifies a red color using a CSS color name.

Example: "#0000ff" specifies a blue color using a hexadecimal RGB value.

Example: "rgb(128,0,128)" specifies a purple color using a decimal RGB color value.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Whether to use bold for this document element, specified as a logical 1 (true) or 0 (false). When you specify:

  • 1 (true) — Render document element in bold text.

  • 0 (false) — Render document element in regular weight.

Note

Setting the Bold property adds a corresponding mlreportgen.dom.Bold format object to the Style property. Setting the Bold property to an empty value removes the object.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: logical

Document element object color, specified as a character vector or string scalar that contains a CSS color name, hexadecimal RGB value, or decimal RGB value.

FormatValue
CSS color nameSpecify a CSS color name. For a list of CSS color names, see https://www.w3.org/wiki/CSS/Properties/color/keywords.
Hexadecimal RGB valueUse the format "#RRGGBB". Use # as the first character and two-digit hexadecimal numbers for the red, green, and blue values. You can use uppercase or lowercase letters.
Decimal RGB color valueUse the format "rgb(r,g,b)", where r, g, and b are comma-separated positive integers that specify the red, green, and blue values, respectively. Each value range must be between 0 and 255.

Setting the Color property adds a corresponding mlreportgen.dom.Color format object to the Style property. Setting the Color property to an empty value removes the object.

Example: "red" specifies a red color using a CSS color name.

Example: "#0000ff" specifies a blue color using a hexadecimal RGB value.

Example: "rgb(128,0,128)" specifies a purple color using a decimal RGB color value.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Indentation amount for the fist line of this paragraph specified as a character vector or string scalar that contains a number followed by an abbreviation for a unit of measurement. For example, "0.5in" specifies one-half inch. Valid abbreviations are:

  • "px" — Pixels

  • "cm" — Centimeters

  • "in" — Inches

  • "mm" — Millimeters

  • "pc" — Picas

  • "pt" — Points

You can also specify pixels by omitting the unit. For example, "5" specifies 5 pixels.

The indentation amount is the amount by which to indent the first line of this paragraph relative to the succeeding lines. To create a hanging indent where all of the lines are indented except for the first line, use a negative number.

Setting the FirstLineIndent property adds a corresponding mlreportgen.dom.FirstLineIndent format object to the Style property for this document element. Setting the FirstLineIndent property to an empty value removes the object.

Example: "0.5in"

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Name of a font family to use for text, specified as a character vector or string scalar. To specify substitutions for the font, do not specify the font family by setting this property. Instead, create and add an mlreportgen.dom.FontFamily object to the Style property.

Setting the FontFamilyName property adds a corresponding mlreportgen.dom.FontFamily format object to the Style property. Setting the FontFamilyName property is the same as setting the FontName property of an mlreportgen.dom.FontFamily object. Setting the FontFamilyName property to an empty value removes the object.

Example: "Courier New"

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Font size for document element specified as a character vector or string scalar that contains a number followed by an abbreviation for a unit of measurement. For example, "12pt" specifies twelve points. Valid abbreviations are:

  • "px" — Pixels

  • "cm" — Centimeters

  • "in" — Inches

  • "mm" — Millimeters

  • "pc" — Picas

  • "pt" — Points

Setting the FontSize property adds a corresponding mlreportgen.dom.FontSize format object to the Style property. Setting the FontSize property to an empty value removes the object.

Example: "12pt"

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Horizontal alignment for this paragraph, relative to page margins or table cell borders, specified as one of the values in this table.

ValueDescriptionSupported Output Types

"center"

Center the paragraph.

All

"distribute"

Distribute all characters equally.

Word

"justify"

Align left side of paragraph on left side of page or table entry, and right side of paragraph on the right side of the page or table entry.

All

"KashidaHigh"

Use widest Kashida length.

Kashida is a type of justification used for some cursive scripts, such as Arabic and Persian.

Word

"KashidaLow"

Use lowest Kashida length.

Word

"KashidaMedium"

Use medium Kashida length.

Word

"left"

Align paragraph left.

All

"right"

Align paragraph right.

All

"ThaiDistribute"

Thai language justification.

Word

Setting the HAlign property adds a corresponding mlreportgen.dom.HAlign format object to the Style property for this document element. Setting the HAlign property to an empty value removes the object.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Whether to use italic for document element, specified as a logical 1 (true) or 0 (false). When you specify:

  • 1 (true) — Render document element in italic text.

  • 0 (false) — Render document element in straight text.

Note

Setting the Italic property adds a corresponding mlreportgen.dom.Italic format object to the Style property. Setting the Italic property to an empty value removes the object.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: logical

Left indentation for this paragraph that contains a number followed by an abbreviation for a unit of measurement, specified as a character vector or string scalar. For example, "0.5in" specifies one-half inch. Valid abbreviations are:

  • "px" — Pixels

  • "cm" — Centimeters

  • "in" — Inches

  • "mm" — Millimeters

  • "pc" — Picas

  • "pt" — Points

You can also specify pixels by omitting the unit. For example, "5" specifies 5 pixels.

The left indentation is the space between the left outer boundary of this paragraph and the left inner boundary of its container. This is equivalent to the left indentation property of a Microsoft® Word paragraph.

Setting the OuterLeftMargin property adds a corresponding mlreportGen.dom.OuterMargin format object to the Style property for this document element. Setting the OuterLeftMargin property to an empty value removes the object.

Tip

To indent a paragraph from both the left and right margin of a page, do not set this property. Instead, create an mlreportgen.dom.OuterMargin that specifies the left and right indentations and add the object to the Style property of this paragraph.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Outline level of the paragraph, specified as an integer. Setting the OutlineLevel property causes this paragraph to be included in automatically generated outlines, such as a table of contents. The value specifies the level of the paragraph in the outline. For example, to make a paragraph appear at the top level in an outline, set the OutlineLevel property to 1.

Setting the OutlineLevel property adds a corresponding mlreportgen.dom.OutlineLevel format object to the Style property. Setting the OutlineLevel property to an empty value removes the object.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: int32

Text strikethrough, specified as one of these values:

  • "none" — No strikethrough

  • "single" — Single line

  • "double" — Double line (for Word reports only)

Setting the Strike property adds a corresponding mlreportgen.dom.Strike format object to the Style property for this document element. Setting the Strike property to an empty value removes the object.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Type of underline, specified as one of the values in this table.

Underline valueDescriptionSupported Output Types

"single"

Single line

All

"words"

Underline all characters except spaces

Word

"double"

Double line

Word

"thick"

Thick line

Word

"dotted"

Dotted line

Word

"dottedHeavy"

Thick dotted line

Word

"dash"

Dashed line

Word

"dashedHeavy"

Line with heavy dashes

Word

"dashLong"

Line with long dashes

Word

"dashLongHeavy"

Line with heavy long dashes

Word

"dotDash"

Dot-dash line

Word

"dashDotHeavy"

Heavy dash-dot line

Word

"dotDotDash"

Dot-dot-dash line

Word

"dashDotDotHeavy"

Line with heavy dashes and two dots between the dashes

Word

"wave"

Wavy line

Word

"wavyHeavy"

Heavy wavy

Word

"wavyDouble"

Double wavy line

Word

"none"

No underline

All

To specify both the color and the type of the underline, do not set the Underline property. Instead, set the Style property to include an mlreportgen.dom.Underline format object that specifies the underline type and color.

Setting the Underline property adds a corresponding mlreportgen.dom.Underline format object to the Style property. Setting the Underline property to an empty value removes the object.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

How to treat white space and line breaks in text, specified as one of the values in this table. The WhiteSpace property does not apply when the Type property of the Document object is PDF.

ValueDescriptionSupported Output Types

"normal"

For HTML and PDF, this value removes spaces at the beginning and the end of text. Multiple spaces in the text collapse to a single space.

For Microsoft Word, this value removes spaces at the beginning and end of text.

All

"nowrap"

Sequences of white space collapse into a single white space. Text never wraps to the next line.

HTML

"pre"

Preserves white space. Text wraps only on line breaks. Acts like the <pre> tag in HTML.

HTML and PDF

"preserve"

Same as "pre".All

"pre-line"

Sequences of white space collapse into a single white space. Text wraps when necessary and on line breaks.

HTML and PDF

"pre-wrap"

Preserves white space. Text wraps when necessary and on line breaks.

HTML and PDF

Setting the WhiteSpace property adds a corresponding mlreportgen.dom.WhiteSpace format object to the Style property. Setting the WhiteSpace property to an empty value removes the object.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Name of stylesheet-defined style, specified as a character vector or string scalar. The style name is the name of a style specified in the style sheet of the document or document part to which this element is appended. The specified style defines the appearance of this element in the output document unless the formats specified by the Style property of this element override it. To learn more about using style sheets, see Use Style Sheet Styles.

Note

Microsoft Word reports ignore style names that are not defined in the document template. For more information on Microsoft Word templates, see Templates for DOM API Report Programs.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Format specification for this document element object, specified as a cell array of DOM format objects. The formats specified by this property override corresponding formats specified by the StyleName property of this element. Formats that do not apply to this document element object are ignored.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: cell

Custom attributes of the document element, specified as an array of mlreportgen.dom.CustomAttribute objects. The custom attributes must be supported by the output format of the document element to which this object is appended.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

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

Attributes:

GetAccess
public
SetAccess
private
NonCopyable
true

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

Attributes:

GetAccess
public
SetAccess
private
NonCopyable
true

Tag, 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. Use this value to help identify where an issue occurs during document generation.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Object identifier, specified as a character vector or string scalar. The DOM API generates a session-unique identifier when it creates the document element object.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Methods

expand all

Examples

collapse all

This example shows how to add three levels of headings, each formatted according to its level. This example inserts three heading objects into a document: a Heading1, a Heading2, and a Heading3.

import mlreportgen.dom.*;
d = Document('mydoc','docx');
open(d);

title = append(d, Paragraph('Document Title'));
title.Bold = true;
title.FontSize = '28pt';

h1 = append(d,Heading1('Chapter 1'));
h1.Style = {PageBreakBefore(true)};
p1 = append(d,Paragraph('Hello World'));

h2 = append(d,Heading2('Section 1.1'));
p2 = append(d,Paragraph('Text for this section.'));

h3 = append(d,Heading3('My Subsection 1.1.a'));
p3 = append(d,Paragraph('Text for this subsection'));

close(d);
rptview(d.OutputPath);

More About

expand all

Version History

Introduced in R2016a