Paragraph — Aspose.Slides FOSS for .NET API Reference

The Paragraph class represents a single paragraph inside a TextFrame. Each paragraph contains one or more Portion objects (runs of uniformly formatted text) and has its own ParagraphFormat controlling alignment, spacing, indentation, and bullets.

Package: Aspose.Slides.Foss (net9.0)

using Aspose.Slides.Foss;
public class Paragraph : IParagraph

Constructors

SignatureDescription
Paragraph()Create a new empty paragraph.

Properties

PropertyTypeAccessDescription
PortionsIPortionCollectionReadCollection of text portions in this paragraph.
ParagraphFormatIParagraphFormatReadParagraph-level formatting (alignment, spacing, bullets).
TextstringReadConcatenated text of all portions.
SlideIBaseSlide?ReadSlide containing this paragraph.
PresentationIPresentation?ReadParent presentation.

ParagraphFormat Properties

The IParagraphFormat object exposed by ParagraphFormat includes:

PropertyTypeDescription
AlignmentTextAlignmentHorizontal text alignment.
SpaceWithinfloatLine spacing within the paragraph.
SpaceBeforefloatSpace before the paragraph.
SpaceAfterfloatSpace after the paragraph.
IndentfloatFirst-line indent.
MarginLeftfloatLeft margin.
MarginRightfloatRight margin.
DepthintOutline/indentation depth level.
BulletIBulletFormatBullet settings.
DefaultPortionFormatPortionFormatDefault formatting for new portions.
RightToLeftNullableBoolRight-to-left text direction.
FontAlignmentFontAlignmentVertical font alignment.

Usage Examples

Create Paragraphs with Portions

using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Export;

using var prs = new Presentation();
var shape = prs.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 50, 50, 400, 200);
shape.AddTextFrame("");

var tf = shape.TextFrame;
tf.Paragraphs[0].Portions[0].Text = "First line";

var p2 = new Paragraph();
p2.Portions.Add(new Portion("Second line"));
tf.Paragraphs.Add(p2);

prs.Save("paragraphs.pptx", SaveFormat.Pptx);

Read Paragraph Formatting

using Aspose.Slides.Foss;

using var prs = new Presentation("deck.pptx");
var shape = prs.Slides[0].Shapes[0] as IAutoShape;
if (shape?.TextFrame != null)
{
    foreach (var para in shape.TextFrame.Paragraphs)
    {
        Console.WriteLine($"Text: {para.Text}");
        Console.WriteLine($"  Alignment: {para.ParagraphFormat.Alignment}");
        Console.WriteLine($"  Depth: {para.ParagraphFormat.Depth}");
    }
}

See Also