Alignment

ParagraphFormat.Alignment property

Returns or sets the text alignment in a paragraph with no inheritance. Read/write TextAlignment.

public TextAlignment Alignment { get; set; }

Examples

The following sample code shows how to Align Text Paragraphs in PowerPoint Presentation.

[C#]
// Instantiate a Presentation object that represents a PPTX file
using (Presentation pres = new Presentation("ParagraphsAlignment.pptx"))
{
    // Accessing first slide
    ISlide slide = pres.Slides[0];
    // Accessing the first and second placeholder in the slide and typecasting it as AutoShape
    ITextFrame tf1 = ((IAutoShape)slide.Shapes[0]).TextFrame;
    ITextFrame tf2 = ((IAutoShape)slide.Shapes[1]).TextFrame;
    // Change the text in both placeholders
    tf1.Text = "Center Align by Aspose";
    tf2.Text = "Center Align by Aspose";
    // Getting the first paragraph of the placeholders
    IParagraph para1 = tf1.Paragraphs[0];
    IParagraph para2 = tf2.Paragraphs[0];
    // Aligning the text paragraph to center
    para1.ParagraphFormat.Alignment = TextAlignment.Center;
    para2.ParagraphFormat.Alignment = TextAlignment.Center;
    //Writing the presentation as a PPTX file
    pres.Save("Centeralign_out.pptx", SaveFormat.Pptx);
}

See Also