Free Support Forum - aspose.com

Shape as placeholder instance

Hi,


In attached file on first slide are shape that the Aspose.Slides recognize as instance of Shape and Placeholder. If you execute following code you can see it:

Presentation presentation = new Presentation(
“path/extract-support-test.ppt”);
Slide slide = presentation.getSlides().get_Item(0);
Placeholders placeholders = slide.getPlaceholders();
for (int placeholderIndex = 0; placeholderIndex < placeholders
.getCount(); placeholderIndex++) {
Placeholder placeholder = placeholders.get_Item(placeholderIndex);
TextHolder textHolder = (TextHolder) placeholder;
Paragraphs paragraphs = textHolder.getParagraphs();
for (int i = 0; i < paragraphs.getCount(); i++) {
Paragraph paragraph = paragraphs.get_Item(i);
System.out.println(paragraph.getText());
}
}
Shapes shapes = slide.getShapes();
for (int shapeIndex = 0; shapeIndex < shapes.getCount(); shapeIndex++) {
Shape shape = shapes.get_Item(shapeIndex);
if (shape.getTextFrame() != null) {
TextFrame textFrame = shape.getTextFrame();
Paragraphs paragraphs = textFrame.getParagraphs();
for (int i = 0; i < paragraphs.getCount(); i++) {
Paragraph paragraph = paragraphs.get_Item(i);
System.out.println(paragraph.getText());
}
}
}
}

This was not happened with version Slides 2.8.0. Can you help me with this please?

Thanks,
Bojan

Hi Bojan,


Thanks for inquiring Aspose.Slides.

I have worked with the sample code and presentation shared using Aspose.Slides for Java 6.7.1. I have yielded the following output on my end.

Paragraph without numbers
Paragraph without numbers
12345534
11-11-2008


Can you please explain what issue you are having on your end. In your presentation there is only one placeholder and that is title. Other two are normal shapes.

Many Thanks,

When I execute just the code for printing text from shapes :


Shapes shapes = slide.getShapes();
for (int shapeIndex = 0; shapeIndex < shapes.getCount(); shapeIndex++) {
Shape shape = shapes.get_Item(shapeIndex);
if (shape.getTextFrame() != null) {
TextFrame textFrame = shape.getTextFrame();
Paragraphs paragraphs = textFrame.getParagraphs();
for (int i = 0; i < paragraphs.getCount(); i++) {
Paragraph paragraph = paragraphs.get_Item(i);
System.out.println(paragraph.getText());
}
}
}

the output is:
Paragraph without numbers
12345534
11-11-2008

for printing text from Placeholders:

Placeholders placeholders = slide.getPlaceholders();
for (int placeholderIndex = 0; placeholderIndex < placeholders
.getCount(); placeholderIndex++) {
Placeholder placeholder = placeholders.get_Item(placeholderIndex);
TextHolder textHolder = (TextHolder) placeholder;
Paragraphs paragraphs = textHolder.getParagraphs();
for (int i = 0; i < paragraphs.getCount(); i++) {
Paragraph paragraph = paragraphs.get_Item(i);
System.out.println(paragraph.getText());
}
}

the output is:
Paragraph without numbers

So, Aspose.Slides recognize that the Slide have one Placeholder (Paragraph without numbers) and three Shapes(Paragraph without numbers, 12345534, 11-11-2008), but you said “In your presentation there is only one placeholder and that is title. Other two are normal shapes.”, this is problem?

Hi Bojan,


I like to share that this is neither an issue with Aspose.Slides nor it is issue with presentation. Placeholder are part of shapes but not every shape is a placeholder. There are two different types of text containers. The placeholders are added in layout or master slides in MainMaster view and when you apply the certain master slide to your slide the placeholders gets reflected on your added slide. Like if you choose a body slide, it will include two placeholders from master that will include title and body placeholders. The other normal text shapes that you will add in your slide will not be considered as placeholders. Please visit this documentation link for your further kind reference.

Many Thanks,

Thanks for reply,


This is happened with every Ppt files when I have some text in layout, you can see attached file and check it. Text from layout are in a Placeholder and in a Shape, why?

Thanks


Hi Bojan,


I like to share that in slide placeholder are part of shape and every placeholder is instance of shape. But every shape is not a placeholder. That is why for the Title Placeholder with text, “Text” you are able to access both in PlacholderCollection and ShapeCollection. I would also suggest you to please visit this technical article where by we have extracted text from every shape inside presentation. You will see three different types of text containers.

Many Thanks,