How to set the indent style for the paragraph on presentation slide in C#

Spire.Presentation supports to operate the paragraph styles from code. There are two kinds of special indentation styles for the paragraph, first line and hanging. This article will demonstrate how to set the indent style for the paragraph on presentation slide in C#.

Step 1: Create an instance of presentation and load the document from file.

Presentation presentation = new Presentation();
presentation.LoadFromFile("Sample.pptx");

Step 2: Get the paragraphs from the first slide.

IAutoShape shape = (IAutoShape)presentation.Slides[0].Shapes[0];
ParagraphCollection paras = shape.TextFrame.Paragraphs;

Step 3: Set the indentation as first line for the first paragraph.

paras[0].Indent = 20;
paras[0].SpaceAfter = 10;

Step 4: Set the indentation as Hanging for the third paragraph.

paras[2].Indent = -100;
paras[2].LeftMargin = 30;

Step 5: Save the document to file.

presentation.SaveToFile("Result.pptx", FileFormat.Pptx2010);

Effective screenshot of the presentation with indentation style:

How to set the indent style for the paragraph on presentation slide in C#

Full codes:

using Spire.Presentation;
using Spire.Presentation.Collections;
namespace SetIndentStyle
{
    class Program
    {
        static void Main(string[] args)
        {

            Presentation presentation = new Presentation();
            presentation.LoadFromFile("Sample.pptx");

            IAutoShape shape = (IAutoShape)presentation.Slides[0].Shapes[0];
            ParagraphCollection paras = shape.TextFrame.Paragraphs;

            paras[0].Indent = 20;
            paras[0].SpaceAfter = 10;

            paras[2].Indent = -100;
            paras[2].LeftMargin = 30;

            presentation.SaveToFile("Result.pptx", FileFormat.Pptx2010);
        }
    }
}