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.

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

example

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

Data Types: logical

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.

Data Types: char | string

Object identifier for the mlreportgen.ppt.AutoFit object, specified as a character vector or string scalar. The PPT 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

Tag for the mlreportgen.ppt.AutoFit object, specified as a character vector or string scalar. The PPT 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

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