Main Content

mlreportgen.ppt.Picture class

Package: mlreportgen.ppt

Picture to include in presentation

Description

Use an object of the mlreportgen.ppt.Picture class to include a picture in a presentation.

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

Class Attributes

ConstructOnLoad
true
HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

pictureObj = mlreportgen.ppt.Picture() creates an empty Picture object.

example

pictureObj = mlreportgen.ppt.Picture(picturePath) creates a Picture object that contains the picture specified by picturePath.

Note

The contents of the specified picture file are copied into the output presentation when the presentation is closed. Do not delete or overwrite the picture file before it is copied into the presentation. If you create a picture file and the corresponding mlreportgen.ppt.Picture object in a loop, use a unique file name for the picture file in each loop iteration.

Input Arguments

expand all

Path and name of a picture file, specified as a string scalar or character vector. The PPT API supports the image formats in the table.

Image FormatFile Extension
Bitmap.bmp
Enhanced Metafile.emf
Encapsulated PostScript®.eps
Graphics Interchange Format .gif
Joint Photographic Experts Group.jpeg, .jpg
Portable Network Graphics.png
Scalable Vector Graphics.svg
Tagged Image File Format.tif, .tiff

Note

To ensure that your version of PowerPoint® supports the image formats used in your generated presentation, see File formats that are supported in PowerPoint on the Microsoft® website.

Properties

expand all

Picture name, specified as a string scalar or character vector.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Upper-left x-coordinate position of the picture, specified as a string scalar or character vector that consists of a number followed by an abbreviation for a unit of measurement. For example, "5in" specifies five inches. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Upper-left y-coordinate position of the picture, specified as a string scalar or character vector that consists of a number followed by an abbreviation for a unit of measurement. For example, "5in" specifies five inches. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Width of the picture, specified as a string scalar or character vector that consists of a number followed by an abbreviation for a unit of measurement. For example, "5in" specifies five inches. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Height of the picture, specified as a string scalar or character vector that consists of a number followed by an abbreviation for a unit of measurement. For example, "5in" specifies five inches. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Picture placeholder formatting. This property is ignored.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Child elements of this PPT API object, specified as a cell array of PPT API objects.

Attributes:

GetAccess
public
SetAccess
private
NonCopyable
true

Parent of this PPT API object, specified as a PPT API object.

Attributes:

GetAccess
public
SetAccess
private
NonCopyable
true

Tag for this PPT API object, specified as a string scalar or character vector. 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:

GetAccess
public
SetAccess
public
NonCopyable
true

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

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Methods

expand all

Examples

collapse all

Use an mlreportgen.ppt.Picture object to include a picture of an airplane in a presentation.

Create a presentation.

import mlreportgen.ppt.*

ppt = Presentation("myPicturePresentation.pptx");
open(ppt);

Add a slide with a Title and Content layout to the presentation.

add(ppt,"Title and Content");

Create a Picture object using an image of an airplane. Specify the size of the picture.

plane = Picture(which("b747.jpg"));
plane.Width = "5in";
plane.Height = "2in";

Replace the content of the slide with the picture.

replace(ppt,"Content",plane);

Close and view the presentation.

close(ppt);
rptview(ppt);

Here is the generated slide with the image of the airplane:

To add an image of a MATLAB figure to a presentation, this example prints the figure to an image file, creates an mlreportgen.ppt.Picture object from the file, and adds the Picture object to a slide in the presentation.

Create a presentation.

import mlreportgen.ppt.*

ppt = Presentation("myFigurePresentation.pptx");
open(ppt);

Add a slide to the presentation.

slide = add(ppt,"Title and Content");

Add a title to the slide.

replace(slide,"Title","surf(peaks)");

Create a MATLAB figure with a surface plot.

fig = figure;
surf(peaks);

Print the figure to an image file. Do not delete the image file before generating the presentation.

figSnapshotImage = "figSnapshot.png";
print(fig,"-dpng",figSnapshotImage);

Create an mlreportgen.ppt.Picture object using the image file.

figPicture = Picture(figSnapshotImage);

Add the Picture object to the slide.

replace(slide,"Content",figPicture);

Close the presentation.

close(ppt);

Delete the figure and the image file.

delete(fig);
delete(figSnapshotImage);

View the presentation.

rptview(ppt);

Here is the generated slide with the image of the figure:

Compatibility Considerations

expand all

Behavior changed in R2021b

Introduced in R2015b