Main Content

mlreportgen.ppt.AutoFit Class

Namespace: mlreportgen.ppt

Scale text to fit placeholder or text box

Since R2020a

Description

Use an mlreportgen.ppt.AutoFit format object to scale text to fit a placeholder or text box in a PPT API slide. Add an AutoFit object to the Style property of an mlreportgen.ppt.ContentPlaceholder, mlreportgen.ppt.TextBoxPlaceholder, or mlreportgen.ppt.TextBox object.

The mlreportgen.ppt.AutoFit class is a handle class.

Creation

Description

autoFitObj = AutoFit scales text in a content placeholder or text box. Specify the scaling percentage by setting the FontScale property.

example

autoFitObj = AutoFit(tf) scales the text if tf is true. Specify the scaling percentage by setting the FontScale property.

autoFitObj = AutoFit(tf,fontScale) scales the text if tf is true. The text is scaled by the percentage specified by fontScale. See the FontScale property.

Properties

expand all

Whether to scale text to fit a placeholder or text box, specified as one of these values:

  • true — Scales text (default)

  • false — Does not scale text

Text font scaling value, specified as a character vector or string scalar. This property specifies the percentage by which the text font size is scaled. The text is scaled one time using the specified percentage. If the text still does not fit the placeholder or text box, reduce the FontScale value until the text fits.

ID for this PPT API object, specified as a character vector or string scalar. A session-unique ID is generated as part of the object creation. You can specify an ID to replace the generated ID.

Attributes:

NonCopyable
true

Data Types: char | string

Tag for this PPT API object, specified as a character vector or string scalar. A session-unique tag is generated 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 issues occur during presentation generation.

Attributes:

NonCopyable
true

Data Types: char | string

Examples

collapse all

To fit text in a content placeholder, create an mlreportgen.ppt.AutoFit format object with the Value property set to true and add the object to the Style property of an mlreportgen.ppt.ContentPlaceholder object. This example adds one slide where the text is not scaled and one slide where the text is scaled.

Create a presentation.

import mlreportgen.ppt.*
ppt = Presentation("myAutoFitPresentation.pptx");
open(ppt);

Add the first slide to the presentation. The content placeholder in this slide does not scale the text to fit.

slide1 = add(ppt,"Title and Content");
contentPlaceholder = find(slide1,"Content");
replace(contentPlaceholder,Paragraph(char(randi(25,1,1000)+97)));
contentPlaceholder.Style = [contentPlaceholder.Style {AutoFit(false)}];

Add the second slide to the presentation. The content placeholder in this slide scales the text to fit.

slide2 = add(ppt,"Title and Content");
contentPlaceholder = find(slide2,"Content");
replace(contentPlaceholder(1),Paragraph(char(randi(25,1,1000)+97)));
contentPlaceholder.Style = [contentPlaceholder.Style {AutoFit(true)}];

Close and view the presentation.

close(ppt);
rptview(ppt);

Version History

Introduced in R2020a