How to get prompt text of placeholder


#1

Hello,

I need to find placeholder in presentation by its custom prompt text. Not text, not alternative text, not name of the placeholder, but the prompt text. I can’t find how to get this property from neither placeholder object, nor shape. Can you help me with that?

Please find presentation with placeholders attached. Prompt text there is [1] in first placeholder, and [2] in second. Placeholders.zip (21.5 KB)


#2

@grevick,

I have observed your requirements and like to share that prompt text that you trying to access is an automatic text set by PowerPoint. In real sense it is not available in Placeholder TextFrame. Therefore, it is not possible to access this text using API as well.


#3

Thanks for the quick response, however it is not always automatic. As you can see in attached presentation, I’ve modified layout in Slide Master, setting prompt text in these placeholders to “[1]” and “[2]”.

So Aspose doesn’t provide possibility to read placeholder prompt text? Is it by any chance planned to do in future releases?


#4

@grevick,

I have created an issue with ID SLIDESNET-40689 as new feature request to further investigate possibility of implementing requested support. This thread has been linked with the issue so that you may be notified once the support will be available.


#5

@grevick,

We have investigated your requirements. This text (“Please click…”) generated by PowerPoint for these placeholders, it does not exist in a document itself and we didn’t have it in Slides. You may add it manually too, as an option if it is really required:

using (Presentation pres = new Presentation("pres.pptx"))
{
    ISlide slide = pres.Slides[0];
    foreach (IShape shape in slide.Slide.Shapes) // iterate through the slide
    {
        if (shape.Placeholder != null && shape is AutoShape)
        {
            string text = "";
            if (shape.Placeholder.Type == PlaceholderType.CenteredTitle) // title - the text is empty, PowerPoint displays "Click to add title". 
            {
                text = "Click to add title";
            }
            else if (shape.Placeholder.Type == PlaceholderType.Subtitle) // the same for subtitle.
            {
                text = "Click to add subtitle";
            }

            Console.WriteLine($"Placeholder with text: {text}");
        }
    }
}