mlreportgen.dom.Text class
Package: mlreportgen.dom
Text object
Description
Use an object of the mlreportgen.dom.Text
class to include text in a
document.
The mlreportgen.dom.Text
class is a handle
class.
Class Attributes
HandleCompatible | true |
ConstructOnLoad | true |
Creation
Description
creates an empty textObj
= mlreportgen.dom.Text()Text
object.
creates a textObj
= mlreportgen.dom.Text(text
)Text
object that contains the specified text and
sets the Content
property to text
.
also specifies the style and sets the textObj
= mlreportgen.dom.Text(text
,styleName
)StyleName
property
to styleName
. You must define the style in the style sheet
in the template of the document to which you append this Text
object.
Properties
Content
— Text contained by this document element
character vector | string scalar
Text contained by this document element, specified as a character vector.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Bold
— Whether to use bold for text
[]
(default) | true
or 1
| false
or 0
Whether to use bold for text, specified as a numeric or logical 1
(true
) or 0
(false
). To make text bold, set Bold
to true
or 1
.
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 |
Italic
— Whether to use italic for text
[]
(default) | true
or 1
| false
or 0
Whether to use italic for text, specified as a numeric or logical 1
(true
) or 0
(false
). To make text italic, set Italic
to true
or 1
.
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 |
Color
— Text color
[]
(default) | character vector | string scalar
Text color, specified as a character vector or string scalar that consists of a CSS color name (see https://www.w3.org/wiki/CSS/Properties/color/keywords) or a hexadecimal RGB (truecolor) value in the form #RRGGBB
.
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: "blue"
Example: "#0000ff"
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
BackgroundColor
— Background color
[]
(default) | character vector | string scalar
Background color, specified as a character vector or string scalar that consists of a CSS color name (see https://www.w3.org/wiki/CSS/Properties/color/keywords) or a hexadecimal RGB (truecolor) value in the form #RRGGBB
.
Setting the BackgroundColor
property adds a corresponding mlreportgen.dom.BackgroundColor
format object to the Style
property. Setting the BackgroundColor
property to an empty value removes the object.
Example: "blue"
Example: "#0000ff"
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Underline
— Type of underline
[]
(default) | "single"
| "none"
| ...
Type of underline, specified as one of the values in this table.
Underline value | Description | Supported Output Types |
---|---|---|
| Single line | All |
| Underline all characters except spaces | Word |
| Double line | Word |
| Thick line | Word |
| Dotted line | Word |
| Thick dotted line | Word |
| Dashed line | Word |
| Line with heavy dashes | Word |
| Line with long dashes | Word |
| Line with heavy long dashes | Word |
| Dot-dash line | Word |
| Heavy dash-dot line | Word |
| Dot-dot-dash line | Word |
| Line with heavy dashes and two dots between the dashes | Word |
| Wavy line | Word |
| Heavy wavy | Word |
| Double wavy line | Word |
| No underline | All |
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.
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.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
WhiteSpace
— White space and line breaks in text
[]
(default) | "normal"
| "nowrap"
| ...
Type of white space and line breaks to use in text, specified as one of
the values in the table. The WhiteSpace
property does not
apply when the Type
property of the
Document
object is PDF.
Value | Description | Supported Output Types |
---|---|---|
| Does not preserve white space and line breaks. | Word and HTML |
| Sequences of white space collapse into a single white space. Text never wraps to the next line. | HTML |
| Preserves white space. Text wraps when necessary
and on line breaks. Acts like the
| Word and HTML |
| Preserves white space. Text wraps only on line
breaks. Acts like the | HTML |
| Sequences of white space collapse into a single white space. Text wraps. | HTML |
| Preserves white space. Text wraps when necessary and on line breaks | HTML |
If you want to view HTML output in the MATLAB® browser and you want to preserve white space and wrap text
only on line breaks, use the preserve
setting instead of
the pre
setting.
Setting the WhiteSpace
property adds a corresponding
WhiteSpace
format object to Style
property. Removing the WhiteSpace
property setting
removes the WhiteSpace
object.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
FontFamilyName
— Name of font family for text
[]
| character vector | string scalar
Name of a font family to use for text, specified as a character vector or string scalar.
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.
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.
Example: "Courier New"
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
FontSize
— Font size for text
[]
(default) | character vector | string scalar
Font size to use for text, specified as a character vector or string scalar that consists of a number followed by an abbreviation for a unit of measurement. For example, '12pt'
specifies twelve points. Valid abbreviations are:
px
— pixels (default)cm
— centimetersin
— inchesmm
— millimeterspc
— picaspt
— 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 |
Strike
— Text strikethrough
[]
(default) | "none"
| "single"
| "double"
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 |
StyleName
— Style for text
character vector | string scalar
You must define the style in the style-sheet in the template of the
document to which you append this Text
object.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Style
— Text formatting
cell array of DOM format objects
Text formatting, specified as a cell array of DOM format objects.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
CustomAttributes
— Custom attributes of document element
array of mlreportgen.dom.CustomAttribute
objects
Custom attributes of this document element, specified as an array of
mlreportgen.dom.CustomAttribute
objects. The custom attributes
must be supported by the output format of the Document
object to which this Text
object is appended..
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Parent
— Parent of this DOM API object
DOM API object
Parent of this DOM API object, specified as a DOM API object.
Attributes:
GetAccess | public |
SetAccess | private |
NonCopyable | true |
Children
— Children of this DOM API object
array of DOM API objects
Children of this DOM API object, specified as an array of DOM API objects.
Attributes:
GetAccess | public |
SetAccess | private |
NonCopyable | true |
Tag
— Tag for this DOM API object
character vector | string scalar
Tag for this DOM API object, specified as a character vector or string scalar.
The DOM 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. Specifying your own tag value can
help you to identify where an issue occurred during document generation.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Id
— ID for this DOM API object
character vector | string scalar
ID for this DOM API object, specified as a character vector or string scalar. The DOM generates a session-unique ID when it creates the document element. You can specify your own ID.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Methods
Public Methods
Method | Purpose |
---|---|
Append a custom element to this text object. Use the
| |
Copy this text object. Use the |
Examples
Format Paragraph Text by Using Separate Text Objects
In this example, you format a paragraph by using two separate mlreportgen.dom.Text
objects so that each piece of text can have its own style. The first Text
object underlines and bolds the text. The second Text
object uses the default style.
Import the DOM API package so that you do not have to use long, fully qualified names.
import mlreportgen.dom.*
Create a Document
object.
d = Document("mydoc","html");
Create a Paragraph
object.
para = Paragraph();
Create a Text
object for the text that you want to bold and underline. Append the Text
object to the Paragraph object,
paraTitle = Text("Results:"); paraTitle.Bold = true; paraTitle.Underline = "single"; append(para,paraTitle);
Create a Text
object for the rest of the text in the paragraph and append the Text
object to the Paragraph
object.
paraContent = Text(" Study 1");
append(para,paraContent);
append(d,para);
Close and view the report.
close(d); rptview(d);
Here is the generated paragragh:
Version History
Introduced in R2014b
Ouvrir l'exemple
Vous possédez une version modifiée de cet exemple. Souhaitez-vous ouvrir cet exemple avec vos modifications ?
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)