Free Support Forum - aspose.com

How to differentiate between placeholder text box and normal text box?

Hi,

I am having 2 textbox in a layout “Cover slide #2”. I have to only select a text box which will be type of “text box 1”.

Attaching a zip which is having presentation file.
slide.zip (21.2 KB)

How we can differentiate between “text box 1” and “text box 2”?

Thanks.

@saquibs,
Thank you for your request.
You can check a placeholder for a shape as below:

if(shape.isTextHolder())
{
   // some code...
}

API Reference: IShape interface

You can check the text box by the text as below:

if(shape instanceof IAutoShape)
{
    ITextFrame textFrame = ((IAutoShape)shape).getTextFrame();
    if(textFrame.getText().contains("[Text box 1]"))
    {
        // some code...
    }
}

More details: Manage TextBox
API Reference: IAutoShape interface, ITextFrame interface

@Andrey_Potapov Hi,

Thanks for the solution.

But the text inside the placeholder will not be constant like “[Text box 1]” just provided for example.
It there any other way to select Placeholder with the help of type or something else?
Both the placeholder are of different type you can able to view by adding blank slide in powerpoint presentation.

Thanks.

@saquibs,
As you can see, the “Text box 2” has a placeholder only. You can check a placeholder type as below:

if(shape.isTextHolder())
{
    byte placeholderType = shape.getPlaceholder().getType(); // PlaceholderType value
    // some code...
}

More details: Manage Placeholder
API Reference: IPlaceholder interface, PlaceholderType class