Aspose.Slides Hanging Indent

Is it possible to set the hanging indent for bulleted lists in Aspose.Slides for Java?

-Paul

Dear Paul,

I am sorry for the delayed response.

Please use the code snippet below for hanging indents using Aspose.Slides for Java in PPT. Please share with us, if you feel any problem.

Presentation pres = new Presentation();
//Get first slide
Slide sld = pres.getSlideByPosition(1);

//Add a rectangle with some dimensions i.e X, Y, Width, Height
com.aspose.slides.Shape shp = sld.getShapes().addRectangle(100, 100, 3000, 1);

//Add a textframe inside a shape
TextFrame tf2 = shp.addTextFrame("");

//Set wrap text true, so that text is wrapped
//if it exceeds the textframe width
tf2.setWrapText (true);

//Set fit shape to text true, so that it can grow
//if text exceeds the textframe height
tf2.setFitShapeToText (true);

//Access the first paragraph
Paragraph para = tf2.getParagraphs().get(0);

//This is an offset of text from the left line
//of textframe's rectangle
para.setTextOffset ((short)200);//setTextOffset (200);

//Access its portion to set text
Portion port = para.getPortions().get(0);

//Set sample text
port.setText ( "This is a paragraph. This is a part of paragraph. This is still another part of paragraph.");

//Just for illustration, create the copy
//of the above paragraph and add again
para = new Paragraph(para);
tf2.getParagraphs().add(para);

//Reset Y position of the rectangle
//because when textframe will grow automatically, the Y position
//will not remain the same we set earlier
int y1 = shp.getY();
shp.setY( 100);

//Write the presentation in output directory.
pres.write("D:\\output.ppt");

Thanks and Regards,

Thank you but that’s not quite what we’re looking for. We’re working with bulleted lists and are able to set the initial indent without problem but the indent is lost when the text wraps. I’ve attached some screenshots of what we currently have (hangingIndentNO.PNG) and what we’re looking to achieve (hangingIndentYES.PNG).

We’re working within the Paragraph object. setHasBullet() and setBulletOffset() functions.

Ideas?

Dear Paul,

Thanks for sharing the image for desired results of hanging bullets. I have modified the code snippet for you to meet your requirement. Please use the code snippet given below to achieve your goal.

Presentation pres = new Presentation();
//Get first slide
Slide sld = pres.getSlideByPosition(1);

//Add a rectangle with some dimensions i.e X, Y, Width, Height
com.aspose.slides.Shape shp = sld.getShapes().addRectangle(100, 100, 3000, 1);

//Add a textframe inside a shape
TextFrame tf2 = shp.addTextFrame("");

//Set wrap text true, so that text is wrapped
//if it exceeds the textframe width
tf2.setWrapText (true);

//Set fit shape to text true, so that it can grow
//if text exceeds the textframe height
tf2.setFitShapeToText (true);

//Access the first paragraph
Paragraph para = tf2.getParagraphs().get(0);


//Set paragraph has numbered bullet type
para.setHasBullet(true);
para.setBulletType(BulletType.NUMBERED );


//This is an offset of text from the left line
//of textframe's rectangle
para.setTextOffset ((short)200);

//Access its portion to set text
Portion port = para.getPortions().get(0);

//Set sample text
port.setText ( "This is a paragraph. This is a part of paragraph. This is still another part of paragraph.");

//Just for illustration, create the copy
//of the above paragraph and add again
para = new Paragraph(para);
tf2.getParagraphs().add(para);

//Reset Y position of the rectangle
//because when textframe will grow automatically, the Y position
//will not remain the same we set earlier
int y1 = shp.getY();
shp.setY( 100);

//Write the presentation in output directory.
pres.write("D:\\output.ppt");

Thanks and Regards,