replace
Class: mlreportgen.ppt.TemplatePicture
Namespace: mlreportgen.ppt
Replace template picture with another picture
Syntax
newPicture = replace(templatePicture,replacementPicture)
Description
replaces a template picture with another picture.newPicture
= replace(templatePicture
,replacementPicture
)
Input Arguments
templatePicture
— Template picture to replace
mlreportgen.ppt.TemplatePicture
object
Template picture to replace, specified as an
mlreportgen.ppt.TemplatePicture
object.
replacementPicture
— Replacement picture
mlreportgen.ppt.Picture
object
Replacement picture, specified as an mlreportgen.ppt.Picture
object.
Output Arguments
newPicture
— New picture
mlreportgen.ppt.Picture
object
New picture in the presentation slide, specified as an
mlreportgen.ppt.Picture
object.
Examples
Replace Template Picture
If you create a presentation from an existing presentation, a picture from the existing presentation (a template picture) is represented by an mlreportgen.ppt.TemplatePicture
object. You can change the position, width, and height of the template picture by setting properties of the object. You can also modify the XML markup of the template picture. To replace the template picture, use the replace method of the TemplatePicture
object. For example, suppose that you create a presentation from an existing presentation myPresentation
that has a slide with the 'Title and Picture'
layout. The following code replaces the template picture with a different picture.
Generate a presentation, MyPicturePresentation
, that you then use as the template presentation for another presentation. MyPicturePresentation
has one slide with one picture.
import mlreportgen.ppt.* ppt = Presentation("MyPicturePresentation"); open(ppt); slide1 = add(ppt,"Title and Picture"); replace(slide1,"Title","Street"); replace(slide1,"Picture",Picture("street1.jpg"));
Close and view the presentation.
close(ppt);
Create a presentation, MyNewPicturePresentation
, from MyPicturePresentation
. MyPicturePresentation
is the template presentation for MyNewPicturePresentation
,
ppt = Presentation("MyNewPicturePresentation","MyPicturePresentation"); open(ppt);
Find the template picture by using the find
method of the slide object. Because the picture comes from a template presentation slide, find
returns the picture as an mlreportgen.ppt.TemplatePicture
object.
slide1 = ppt.Children(1);
templatePictureObj = find(slide1,"Picture")
templatePictureObj = TemplatePicture with properties: XMLMarkup: '<p:pic><p:nvPicPr><p:cNvPr id="8" name="Picture"/><p:cNvPicPr><a:picLocks noChangeAspect="1" noGrp="1"/></p:cNvPicPr><p:nvPr><p:ph idx="13" sz="quarter" type="pic"/></p:nvPr></p:nvPicPr><p:blipFill><a:blip r:embed="rId2"><a:extLst><a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}"><a14:useLocalDpi val="0" xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main"/></a:ext></a:extLst></a:blip><a:stretch><a:fillRect/></a:stretch></p:blipFill><p:spPr/></p:pic>' Name: 'Picture' X: [] Y: [] Width: [] Height: [] Style: [] Children: [] Parent: [1×1 mlreportgen.ppt.Slide] Tag: 'ppt.TemplatePicture:70:263' Id: '70:263'
Replace the picture with a different picture.
street2 = Picture("street2.jpg");
replace(templatePictureObj,street2);
Close and view the presentation.
close(ppt); rptview(ppt);
Version History
Introduced in R2019b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)