Main Content

mlreportgen.dom.TemplateParagraphStyle Class

Namespace: mlreportgen.dom

Style paragraph content within template

Since R2024a

Description

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

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

Class Attributes

HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

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

styleObj = TemplateParagraphStyle(name) creates a paragraph style and initializes the Name property to name.

example

Properties

expand all

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

Note

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

Attributes:

GetAccess
public
SetAccess
public
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:

GetAccess
public
SetAccess
public
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

Examples

collapse all

Create and use a template with a paragraph style defined.

Create a Template and Define the Paragraph Style

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

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

textStyle = TemplateParagraphStyle("myParagraphStyle");

Define formats for the style.

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

Add style to the stylesheet.

addStyle(t.Stylesheet,textStyle);

Close the template.

close(t);

Use the Style From the Template

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

Create a document using the generated template.

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

Create a paragraph object.

para = Paragraph("example text");

Set the style name.

para.StyleName = "myParagraphStyle";

Add the text to the document.

append(d,para);

Close and view the document.

close(d);
rptview(d);

Version History

Introduced in R2024a