Please use the code snippet given below to access the different placeholders in master layout slides. I have shared the converted the .NET code for your reference to Java that completely works with Aspose.Slides for .NET but not with Aspose.Slides for Java completely as one cannot add Placeholder in Java version presently. However, it will still serve your requirement of accessing the placeholders.
public static void GetLayout()
{
String path = “C:\Users\Mudassir\Downloads\”;
PresentationEx presentation = new PresentationEx(path+“placeholdersTemplate.pptx”);
LayoutSlidesEx layouts= presentation.getMasters().get(0).getLayoutSlides();
PlaceholderTypeEx placeholderType=null;
for (int i=0;i< layouts.size();i++)
{
LayoutSlideEx layout=layouts.get(i);
presentation.getSlides().addEmptySlide(layout);
SlideEx slide = presentation.getSlides().get(presentation.getSlides().size() - 1);
ShapesEx shapes=slide.getLayoutSlide().getShapes();
for (int j=0;j<shapes.size();j++ )
{
ShapeEx shape=shapes.get(j);
if (shape.getPlaceholder() != null)
{
placeholderType=shape.getPlaceholder().getType();
int type=0;
placeholderType.toValue(type);
//type=placeholderType.;
switch (placeholderType.getId())
{
default:
slide.getShapes().addAutoShape(
ShapeTypeEx.ROUND_CORNER_RECTANGLE, Float.NaN, Float.NaN, Float.NaN, Float.NaN);
break;
case PlaceholderTypeEx.SLIDE_NUMBER_ID:
{
slide.getShapes().addAutoShape(
ShapeTypeEx.ROUND_CORNER_RECTANGLE, Float.NaN, Float.NaN, Float.NaN, Float.NaN);
AutoShapeEx ashape = (AutoShapeEx)slide.getShapes().get(slide.getShapes().size() - 1);
ashape.addTextFrame(“text”);
ashape.getTextFrame().getParagraphs().get(0).getPortions().get(0).addField(FieldTypeEx.SLIDE_NUMBER);
}
break;
case PlaceholderTypeEx.DATE_AND_TIME_ID:
{
slide.getShapes().addAutoShape(
ShapeTypeEx.ROUND_CORNER_RECTANGLE, Float.NaN, Float.NaN, Float.NaN, Float.NaN);
AutoShapeEx ashape = (AutoShapeEx)slide.getShapes().get(slide.getShapes().size()- 1);
ashape.addTextFrame(“text”);
ashape.getTextFrame().getParagraphs().get(0).getPortions().get(0).addField(FieldTypeEx.DATE_TIME);
}
break;
case PlaceholderTypeEx.OBJECT_ID:
case PlaceholderTypeEx.TABLE_ID:
slide.getShapes().addTable(
Float.NaN, Float.NaN, new double[] { 30, 30, 30 }, new double[] { 20, 20 });
break;
case PlaceholderTypeEx.PICTURE_ID:
{
slide.getShapes().addPictureFrame(
ShapeTypeEx.ELLIPSE, Float.NaN, Float.NaN, Float.NaN, Float.NaN, null);
((AutoShapeEx )shape).getTextFrame() .setText(“Hello World”);
break;
}
//case PlaceholderTypeEx.Diagram:
// // TODO: add diagram insertion here
// break;
case PlaceholderTypeEx.MEDIA_ID:
slide.getShapes().addVideoFrame(Float.NaN, Float.NaN, Float.NaN, Float.NaN, “video.avi”);
break;
}
ShapeEx newShape = slide.getShapes().get(slide.getShapes().size() - 1);
// newShape.addPlaceholder(shape.Placeholder);
}
}
}
presentation.save(path+“placeholders.pptx”, com.aspose.slides .export .SaveFormat.PPTX);
}