Gettin Alternative Text From Shapes Not in Master Slide

Hi - I am able to get the alternative text from a shape that is in a master slide and then created in a slide from that master. Question is - can I get the alternative text from a general text box that is not contained in the master slide. If so how? I cannot seem to get that information.

Hi John,


Thank you for your interest in Aspose.Slides.

I have observed your comments and like to request you to please share with us a sample presentation and share with us from which particular text box do you want to get the alternative text so that we may try to help you out in this regard.

Best Regards,

Yes thank you. Here is a source code snippet and I have attached the powerpoint file. That file has a master slide that contains the text box placholders for ‘Risk Title’ and ‘Risk Owner’ and those work. What I am now trying to do is insert another simple text box called ‘Company’ (not a placeholder on the master slide - it is on the second slide). But I cannot set data in that new textbox using the code below…

Presentation target = new Presentation(dataDir + “Presentation2.pptx”);

ISlide slide = target.getSlides().get_Item(0);

Shape shape = null;

for(int i=0; i < slide.getShapes().size(); i++)
{
shape = (Shape)slide.getShapes().get_Item(i);

if(shape.getPlaceholder()!=null)
{
if(shape.getAlternativeText().equals(“Risk Title”))
((IAutoShape)shape).getTextFrame().setText(“riskTitle”);
else if(shape.getAlternativeText().equals(“Risk Owner”))
((IAutoShape)shape).getTextFrame().setText(“riskOwner”);
else if(shape.getAlternativeText().equals(“Company”))
((IAutoShape)shape).getTextFrame().setText(“New Company Text”);
}
}

Hi John,

I have observed your comments and the presentation file shared by you. I would like to share with you that the mistake you are making is that, you are setting the Alternative Text in Title field whereas it needs to be set in ‘Description’ field instead of ‘Title’ field. (see image “reason.JPG” attached for red color marked explanation). You may set Alternative text of shape by PowerPoint or programatically, while using Aspose.Slides for Java as explained in this article. Then you can find a shape to remove it or to replace text.

I hope this will be helpful. Please let us know if the issue persists. We will be happy to assist you further.

Best Regards,

Right - that was one error on my part. Once that was fixed (it was correct in other text boxes on the slide) the solution I was looking for was that I did not need to check

if(shape.getPlaceholder()!=null)

if the text box was not a place holder then this would never be true.

Hi John,


I have observed your comments but I have not been able to understand them completely. What I have figured out of your comments is that your problem has been solved and you are discussing the reason of the problem. Is that so? Or are you still facing the issue on your end? Please share with us so that we may help you out if the problem persists.

Best Regards,

I was able to figure out my problem.

If you are reading in a powerpoint file and need to fill in text then you do not need to use a master slide and placeholders.

You can simply insert a textbox and set the alternative text on it. Then use that alternative text to reference the textbox to set the text.

Hi John,


I have observed your comments and have found that you are right. This way we can set the text in a textbox.

Please share if I may help you further in this regard.

Best Regards,