Main Content

mlreportgen.dom.TemplateLinkedStyle Class

Namespace: mlreportgen.dom

Style linked content within template

Since R2024a

Description

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

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

Class Attributes

HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

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

styleObj = TemplateLinkedStyle(name) creates a linked style and initializes the Name property to name.

example

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 the mlreportgen.dom.TemplateLinkedStyle 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 the mlreportgen.dom.TemplateLinkedStyle 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 LinkedStyle style defined. You can use a linked style on both Paragraph and Text DOM objects.

Create a Template and Define the LinkedStyle

Create a new template and define a bold, blue LinkedStyle.

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 linked style.

linkedStyle = TemplateLinkedStyle("myLinkedStyle");

Define formats for the linked style.

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

Add style to the stylesheet.

addStyle(t.Stylesheet,linkedStyle);

Close the template.

close(t);

Use the Style From the Template

Create a new document from your template and apply the linked style to a paragraph and a text object.

Create a document using the generated template

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

Create a paragraph object.

para = Paragraph("example paragraph");

Set the style name.

para.StyleName = "myLinkedStyle";

Create a text object.

txt = Text("example text");

Set the style name.

txt.StyleName = "myLinkedStyle";

Add the paragraph and text to the document.

append(d,para);
append(d,txt);

Close and view the document.

close(d);
rptview(d);

Version History

Introduced in R2024a