Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Sun Mar 02, 2025 5:51 pm

Hello I am trying to generate bullets with the default indentation that powerpoint would add.

This is sample code I am using
Code: Select all
            var fileName = @"test.pptx";
            Presentation ppt = new Presentation();
            ppt.LoadFromFile(fileName);
            var finalPpt = new Presentation();
            finalPpt.Slides.RemoveAt(0);
            finalPpt.SlideSize.Type = ppt.SlideSize.Type;
            var generatedSlide = ppt.Slides[0];
            var shape = generatedSlide.Shapes[0];
            var tp = (generatedSlide.Shapes[1] as IAutoShape).TextFrame.Paragraphs[0];
            tp.BulletType = TextBulletType.Symbol;

            finalPpt.Slides.Append(generatedSlide);


however the result is a bullet that has text right next to it. If I try to add a bullet with powerpoint instead i get this indented with different space.
Is there a way to get the same indentation level?

seems like
tp.Indent or tp.DefaultTabSize won't help


Attaching result
lib generated is bullet generated with library while pp generated is bullet generated with defaul pp bullet

Thanks

andreacalvi
 
Posts: 28
Joined: Tue Jul 11, 2023 11:02 am

Mon Mar 03, 2025 8:49 am

Hello,

Thanks for your inquiry.
Please note that Microsoft PowerPoint will set a hanging indent for the paragraph when adding bullets, but Spire.Presentation not, and the default indent is 0. To add an indent value, please refer to the code below. If you have any other questions, please feel free to write back.
Code: Select all
...
foreach (TextParagraph para in shape.TextFrame.Paragraphs)
{
    //Add the bullets
    para.BulletType = TextBulletType.Symbol;
    para.HangingPunctuation = TriState.True;
    para.Indent = -15;
}
...


Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 732
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.Presentation

cron