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

Free Support Forum - aspose.com

Strange beahviour with paragraphs (PPTX)


I have a string containing newlines (\n) and the following code:

String text = “abc\ndef\nghi\njkl”;
TextFrame tf = ( (AutoShapeEx) slide.findShapeByAltText(altText)).getTextFrame();


No matter how many \n’s are in the string - what I get is always exactly two paragraphs; one containing all of the string up to the last \n (in the above example: “abc\ndef\nghi”), and one containing the rest (“jkl”).

However I would expect either that each substring (abc, def, ghi, jkl) will get its own paragraph, or that the whole string is added to one single paragraph.

What I need is to have each substring in its own paragraph, so that I can decide whether it gets a bullet point or not, e.g.

* abc
* jkl

I managed to do it by setting each substring in a new paragraph using tf.getParagraphs().add(newParagraph). However the behaviour described above seems very strange to me so I wanted to report it.

Kind regards

Hi Stefan,

Thanks for you inquiry.

I have used the following code snippet and able to resolve the issue which you were facing.
Note: I am using latest version of Aspose.Slides for Java which can be found here.

<span style=“font-size:10.0pt;font-family:“Times New Roman”,“serif”;
mso-fareast-font-family:“Times New Roman””>
public static void para(){


//Instantiate a PresentationEx class that represents a PPTX file

PresentationEx pres = new PresentationEx();

//Accessing first slide

SlideEx slide = pres.getSlides().get(0);

//Add an AutoShape of Rectangle type

int idx = slide.getShapes().addAutoShape(ShapeTypeEx.RECTANGLE, 50, 150, 300, 150);

AutoShapeEx ashp = (AutoShapeEx)slide.getShapes().get(idx);

//Access TextFrame of the AutoShape

String text = “abc\ndef\nghi\njkl”;

TextFrameEx tf = ashp.getTextFrame();


//Write PPTX to Disk
}catch (IOException e) {
// TODO Auto-generated catch block

Many Thanks.

Hello Hassan,

thank you very much for your help.

Kind regards

Hi Stefan,

Thanks for appreciation,

If you require any further information, please feel free to contact us.

Best Regards