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

Free Support Forum - aspose.com

How to setup hanging punctuation for bullets inside text (C# .NET)

I am trying to alter a text frame and insert bullet points into it. However I have been unable to get hanging punctuation’s to work. In case the text length is greater than the width for the bullet point, it doesn’t maintain the indent of the first line and starts from the very beginning

1 Like

Continuing the discussion from Hanging Punctuation:

    String filePath = "templates/sample-template.pptx";
    InputStream stream = TestSample.class.getClassLoader().getResourceAsStream(filePath);        
    Presentation prs = new Presentation(stream);

    ISlide slide = prs.getSlides().get_Item(0);
    ITextFrame[] textBoxes = SlideUtil.getAllTextBoxes(slide);
    ITextFrame txt = textBoxes[0];
    Paragraph p = new Paragraph();

    txt.getParagraphs().insert(0, p);

My output is something like this…

a. text text
tex text

Instead of

  1. text text
    text text

Sorry for the a and 1 … i couldn’t preserver indentation here :slight_smile:


I suggest you to please try using following example related to hanging punctuation.

public static void SetHangingPunctuation()
    Presentation pres = new Presentation();

    //Accessing first slide
    ISlide slide = pres.getSlides().get_Item(0);
    slide.getShapes().addAutoShape(ShapeType.Rectangle, 0, 50, 500, 300);

    //Accessing the first and second placeholder in the slide and typecasting it as AutoShape
    ITextFrame tf = ((AutoShape)slide.getShapes().get_Item(0)).getTextFrame();

    //Change the text in both placeholders
    tf.setText("Indent by Aspose Indent by Aspose Indent by Aspose Indent by Aspose");

    //Getting the first paragraph of the placeholders
    IParagraph para1 = tf.getParagraphs().get_Item(0);
    String buChar = new String(Character.toChars(8226));
    para1.getParagraphFormat().getBullet().setChar (buChar.charAt(0));

    Paragraph para2 = new Paragraph();
    para2.getParagraphFormat().getBullet().setType (BulletType.Symbol);

    para2.setText("Indent by Aspose Indent by Aspose Indent by Aspose Indent by Aspose Indent by Aspose Indent by Aspose Indent by Aspose Indent by Aspose Indent by Aspose Indent by Aspose Indent by Aspose Indent by Aspose");


    para1.getParagraphFormat().setIndent (-20);
    para2.getParagraphFormat().setIndent (-20);

    para1.getParagraphFormat().setAlignment (TextAlignment.Left);


     para1.getParagraphFormat().setHangingPunctuation (NullableBool.True);
     para2.getParagraphFormat().setHangingPunctuation (NullableBool.True);

    //Writing the presentation as a PPTX file
    pres.save("d:\\MarginIndentAlign.pptx", SaveFormat.Pptx);   

I agree that this works. But what’s the issue with my code?

All I see that is different is margin and indent. What’s the relation of margin and indent with hanging punctuations?


The margin and indent setting adjust the paragraph text to appear properly when using hanging punctuation. I hope the shared example will be helpful.


Its still not consistent. It sometimes works and in some context it doesn’t.

So setting indent to -15 and margin left to 20 gave me the proper design I wanted for bullet points in 1st level.
But the same in second level didn’t work.

For second level I had kept indent at 0 and margin at 35.

Is there a generic different between indent and margin which we need to adhere for hanging punctuation?


You need to set the margin and indents for paragraphs with hanging punctuation. For multilevel bullets, I suggest you to please visit this documentation link for your kind reference.