How do I a replacement of placeholders with images?

68 ビュー (過去 30 日間)
Giovanni Di Lorenzo
Giovanni Di Lorenzo 2024 年 11 月 21 日 11:00
編集済み: Hitesh 2024 年 11 月 22 日 11:02
Hello, everyone. I am working on a project with MATLAB and I'm stuck because I can't insert images in place of placeholders. Could you please help me? I saw that I have to use "TemplateHole" from mlreportgen.dom.* library. Is there a way to make the replacement??

回答 (1 件)

Hitesh
Hitesh 2024 年 11 月 22 日 10:02
編集済み: Hitesh 2024 年 11 月 22 日 11:02
Hi Giovanni,
I am assuming that you are trying to insert image in place of image placeholder in PowerPoint presentation. Kindly follow these steps to accomplish this:
  • Presentation Creation: You need to initialize a new PowerPoint presentation.
  • Slide Addition: After that add a slide with a "Title and Picture" layout.
  • Placeholder Replacement: Replace the title placeholder with the text "Airplane" and the picture placeholder with a specified image.
  • Finalization: Finally, close the presentation and open it for review.
import mlreportgen.ppt.*
% Create a new PowerPoint presentation
ppt = Presentation("myPicturePlaceholderPresentation.pptx");
open(ppt);
% Add a slide with a title and picture layout
slide = add(ppt, "Title and Picture");
% Find and replace the title placeholder with the text "Airplane"
titlePlaceholderObj = find(slide, "Title");
replace(titlePlaceholderObj, "Airplane");
% Find and replace the picture placeholder with the specified image
picturePlaceholderObj = find(slide, "Picture");
replace(picturePlaceholderObj, Picture("Aeroplane.png"));
% Close the presentation and open it for viewing
close(ppt);
rptview(ppt);
For more information regarding "mlreportgen.ppt.PicturePlaceholder" class, kindly refer to the below MATLAB documentation:
If you want to insert the image in image placeholder for Word Document, kindly refer to the below MATLAB documentation for "mlreportgen.dom.EmbeddedObject Class":

カテゴリ

Help Center および File ExchangeCreate Complete PowerPoint Presentations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by