Main Content

Create and Format Text

Create Text

You can create a Text object using an mlreportgen.ppt.Text constructor, specifying a character vector.

Also, you can create text by using a character vector or string scalar with objects of these PPT API classes:

  • Paragraph

  • InternalLink

  • ExternalLink

  • TableEntry

  • TextBox

  • ContentPlaceholder

  • TextBoxPlaceholder

For example:

import mlreportgen.ppt.*;
ppt = Presentation('myPresentation.pptx');
slide1 = add(ppt,'Title Slide');

contents = find(slide1,'Title');
titleText = replace(contents(1),'My Title');

For more information about creating and adding text, see Add and Replace Text.

Create a Subscript or Superscript

You can enable the Subscript or Superscript property for a Text object. Enabling these properties specifies that the text gets treated as a subscript or superscript when you add it to a Paragraph object. For example, you can set up a paragraph to display x2.

super = Text('2');
super.Superscript = true;

para = Paragraph('x');
append(para,super);

Format Text

To format a Text object, use format objects with a Text object Style property or use Text object properties. For example:

t = Text('green text');
t.Style = {Bold(true)};
t.FontColor = 'green';
Text Object Formatting Format ObjectFormat Property

Font family

FontFamily

Font

Font family for complex scripts to handle locales

FontFamily

ComplexScriptFont

Font size

FontSize

FontSize

Font color

FontColor

FontColor

Bold

Bold

Bold

Italic

Italic

Italic

Strike

Strike

Strike

Underline

Underline

Underline

Subscript

Subscript

Subscript

Superscript

Superscript

Superscript

See Also

Classes

Related Examples

More About