Free Support Forum -

FitShapeToText In Aspose Slides (Java)

I’ve been reading several other threads about the FitShapeToText() function, but I can’t seem to find anything about it in Java.

I created a rectangle of size (1,1) and added a textframe to it with the following text:


I then set the FitShapeToText() to true and WrapText() to true as well. However, when I generated the powerpoint file, the textframe has not changed to accomodate the size of the text. Any ideas as to what I could be doing wrong?

Thank you.

Dear mrshmi,

Thanks for considering Aspose.Slides for JAVA.

It seems width of your rectangle is too small to accomodate any visible text.

Below is the JAVA code which adds a rectangle 1000x1. The TextFrame.setFitShapeToText enlarges the rectangle to accomodate text and TextFrame.setWrapText wraps the text if it crosses width of the rectangle. You can also uncomment the line to make rectangle lines invisible.


Presentation srcPres=new Presentation();

Slide sld=srcPres.getSlideByPosition(1);

//Width=1000 but height is 1

com.aspose.slides.Rectangle rect=sld.getShapes().addRectangle(100, 100, 1000, 1);

TextFrame tf=rect.addTextFrame(" ");

tf.setText("Lot of text. Lot of text. Lot of text. Lot of text. Lot of text. Lot of text.Lot of text. Lot of text. Lot of text. Lot of text. Lot of text. Lot of text.");

tf.setFitShapeToText(true); //enlarges the rectangle to accomodate text

tf.setWrapText(true); //wrap the text if it crosses width

//To make rectangle lines invisible, uncomment it to see


srcPres.write(new FileOutputStream(new File("c:\\outAddTextFrame.ppt")));