Cannot retrieve textholder from slide placeholders array

Hi there,

I’m trying to retrieve some text from a placeholder object in a slide, using Aspose Slides.
However, when I try to retrieve the placeholder, which is a textholder object, I get back null.
I have tried assigning it to a placeholder, textholder and object, with no luck. I have the code to do this surrounded by a try catch block but no exception is thrown either, so I’m a bit confused - I was wondering if you could guide me as to where I’m going wrong?

I have attached the file in question with a screenshot of the text I am trying to retrieve.

Kind regards
Eric Chubb

Hi Eric,

Thanks for your interest in Aspose.Slides.

I have observed the presentation file shared by you. You are unable to read the text from one of the shapes in slides because you might be accessing that as TextHolder. Infact, the shape is an instance of Rectangle and if you find such instance, you will be able to access the text inside it. Please use the code snippet given below for accessing the said shape.

Presentation Pres = new Presentation(@"D:\ppt\Jiamcatt+Presentation.ppt");

Slide slide = Pres.Slides[0];

int c = slide.Shapes.Count;

foreach (Aspose.Slides.Shape Shp in slide.Shapes)

{

if (Shp is Aspose.Slides.Rectangle)

{

TextFrame textframe = Shp.TextFrame;

MessageBox.Show(textframe.Text);

}

}

Thanks and Regards,

Hi Mudassir

Thank you for your response. Having checked on our side, our debugger is telling us that the text is contained inside a TextHolder object, itself contained inside the PlaceHolders array for the first slide in the presentation. Please see the attached screenshot. When I try to assign this textholder to a new TextHolder object null is returned.

Thanks
Eric

Hi Eric,

I have observed the snapshot shared by you. There was a little problem on my end. Actually, I opened the shared PPT file in PowerPoint 2007 and it changed all the Placeholders to Recangle shape. The code that I shared earlier, also worked fine for PPT that has been opened in PowerPoint 2007 before using with Aspose.Slides for .NET. Please find the attached code snippet, that has been modified for reading the text from Placeholders.

Presentation Pres = new Presentation(@"D:\ppt\Jiamcatt+Presentation.ppt");

int iSlideCount = 0;

foreach(Slide slide in Pres.Slides)

{

iSlideCount++;

foreach (Aspose.Slides.Shape Shp in slide.Shapes)

{

if(Shp.IsTextHolder)

{

TextHolder Txtholder=Shp.Placeholder as TextHolder;

if(Txtholder!=null)

MessageBox.Show("Slide : " + iSlideCount + ", Shape Text Holder \n" + Txtholder.Text);

}

else if (Shp is Aspose.Slides.Rectangle)

{

TextFrame textframe = Shp.TextFrame;

if(textframe !=null)

MessageBox.Show("Slide : " + iSlideCount + ", Shape Text Frame \n" + textframe.Text);

}

}

}

Hopefully, things will work this time, since I have verified on my end as well.

Thanks and Regards,