Main Content

mlreportgen.dom.TemplateTextStyle Class

Namespace: mlreportgen.dom

Style text content within template

Since R2024a

Description

Use this class to create a Document Object Model (DOM) representation of a text style.

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

Class Attributes

HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

styleObj = TemplateTextStyle creates a text style with an empty name. You must set the Name property to use the style.

example

styleObj = TemplateTextStyle(name) creates a text style and initializes the Name property to name.

Properties

expand all

Name of the style, specified as a string scalar or character vector.

Note

The name must include only letters, numbers, hyphens (-), and underscores (_).

Attributes:

NonCopyable
true

Data Types: char | string

Style sheet formats, specified as an array of DOM formatting objects. These formats define how this style affects report content.

Attributes:

NonCopyable
true

Tag for mlreportgen.dom.TemplateTextStyle 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.TemplateTextStyle 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

Examples

collapse all

Create and use a template with a text style defined.

Create a Template and Define the Text Style

Create a new template and define a bold, blue text style.

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

import mlreportgen.dom.*;
t = Template("myTemplate","pdf");
open(t);

Create a text style.

textStyle = TemplateTextStyle("myTextStyle");

Define formats for the style.

textStyle.Formats = [Bold Color("blue")];

Add the style to the style sheet.

addStyle(t.Stylesheet,textStyle);

Close the template.

close(t);

Use the Style From the Template

Create a new document from your template, and apply your style to a text object.

Create a document using the generated template.

d = Document("myDoc","pdf","myTemplate");
open(d);

Create a text object.

txt = Text("example text");

Set the style name of the text.

txt.StyleName = "myTextStyle";

Add the text to the document.

append(d,txt);

Close and view the document.

close(d);
rptview(d);

Version History

Introduced in R2024a