We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Check if text overflows shape

Hi.

We are trying to check if a text field in the presentation overflows the set size of the shape.

We are using Java 8 and aspose Slides 16.10.0

com.aspose
aspose-slides
LATEST

We have a solution that works in VBA:

If shape.TextFrame.AutoSize <> ppAutoSizeNone Then
'Report an error - we can't test this if the textbox will automatically resize to fit the text
Else
If (shape.TextFrame.TextRange.BoundHeight + shape.TextFrame.TextRange.BoundTop) > (shape.Top + shape.Height) Then
'Text is too long - the bounding box of the text frame is outside the shape
Else
'Text fits
End If
End If

We need to migrate those checks to java but unfortunately we can't seem to produce the same result.

Is there a way to achieve this using the java library?

Thanks,
Ana

Hi Ana,

Thanks for inquiring Aspose.Slides.

I have observed your requirements and like to share that text frame holds the text inside shape of presentation. Aspose.Slides offer TextFrameFormat.AutofitType Property that allows you set the TextAutofit type to either shape or Normal. The Shape autofit property, changes shape size fit the text. Where as Normal autofit type reduced the text font size to accommodate that in given shape boundaries. There is no such property to tell if the text has overflown the shape. Can you please share the sample presentation along with what you want to achieve so that I may investigate further to help you out.

Many Thanks,

Hi.


We are creating powerpoint files based on templates and user input (users write articles in HTML - using templates - and we transform them into powerpoint). We don’t want the powerpoint to change (neither the size of the shape nor the text) but we want to check if the text inputted overflows the fixed text frame so we can warn the user about it so it can be changed.

You can see the powerpoint we are trying to get that information from attached.

Thanks,
Ana

Hi Ana,

I have tried opening the presentation file shared by you and have opened that in PowerPoint. I am unable to get your requirement from presentation and in attached image can you please share where you actually want to map your requirement. Moreover, based on your comments, what I have perceived is some thing like shared in this image. Is this what you want to know if the text frame text has exceeded shape or not? If this is requirement then I like to mention that there is no such support available in this regard. I have also discussed this with our product team in this regard and will share further feedback with you after feedback is being shared by them.

We are sorry for your inconvenience,

Hi.


Sorry for the delay but I didn’t receive a notification of the answer in my email.

You are correct, we need to know if the text frame exceeds the shape is in. Since the power points are generated from HTML and are heavily templated we need to know if the text inserted in the template overflows the space.

We have a workaround for it, where we turn the shape autofit on after creating the slide and if the shape gets bigger it means the text overflows, but it would be nice to have a cleaner way to do it.

Best regards,
Ana

Hi Ana,


I have observed your comments. We are looking into this and will get back to you with feedback soon.

Best Regards,

@mudassir.fayyaz,
can i get Range object or Characters of any TextFrame in Java 8

@prashant.barwe,

I have tried to understand your requirements and have not been able to completely understand that. If you want to access or extract TextFrame text, then I suggest you to please visit documentation article, Replacing TextFrame text.

@mudassir.fayyaz,
my quire is regarding to access shape.TextFrame.TextRange (mentioned in @AnaManuel’s Post) object than i want to work on this TextFrame Characters.

@prashant.barwe,

I have observed your comments and regret to share that there exist no such property TextRange in TextFrame class for Aspose.Slides. Please visit API reference link for TextFrame for available properties.