Class Paragraph
Inheritance
System.Object
Paragraph
Assembly: IronPPT.dll
Syntax
public class Paragraph : ParentElement, ICloneableElement, IParentElement, ITextContainer, IHasTextStyle, IParagraph, IContentElement, IHasParagraphStyle
Adding a block of text to a slide in C# runs through Paragraph. It represents one paragraph of content, the unit a developer builds up with text and then drops onto a slide, and it is what holds the words, their alignment, and their styling together as a single addable element. A Paragraph is the everyday building block behind any slide that carries written content, distinct from a Run, which groups inline content inside richer text.
Create a paragraph with new Paragraph(), or pass content straight to the constructor that takes params IContentElement[]. Fill it by calling AddText with a string or an IText, then attach it to a slide with Slides[index].AddParagraph(paragraph) on a PresentationDocument. That places the paragraph in the render order of the slide, so the sequence of AddParagraph calls is the sequence the reader sees.
Styling is set through the Style property, an IParagraphStyle, which controls bullets, spacing, indentation, and line spacing for the whole paragraph, while TextStyle carries the default ITextStyle for its text. Alignment sets the horizontal TextAlignment, and SetAlignment and SetStyle offer the same in a chainable form that returns the paragraph. Texts exposes the contained IText items for inspection, AddChild appends content elements, and Clone copies the whole paragraph when a slide needs a repeated block.
using IronPPT;
using IronPPT.Models;
var document = new PresentationDocument();
var paragraph = new Paragraph();
paragraph.AddText("First paragraph.");
document.Slides[0].AddParagraph(paragraph);
document.Save("paragraph.pptx");
The add paragraph example builds and places one, the paragraph style example applies styling, and the add text how-to walks through text on a slide.
Constructors
Paragraph()
Declaration
Paragraph(IContentElement[])
Declaration
public Paragraph(params IContentElement[] children)
Parameters
Properties
Alignment
Declaration
public TextAlignment Alignment { get; set; }
Property Value
Style
Declaration
public IParagraphStyle Style { get; set; }
Property Value
Texts
Declaration
public List<IText> Texts { get; }
Property Value
| Type |
Description |
| System.Collections.Generic.List<IText> |
|
TextStyle
Declaration
public ITextStyle TextStyle { get; set; }
Property Value
Methods
AddChild(IContentElement[])
Declaration
public override void AddChild(params IContentElement[] children)
Parameters
Overrides
AddText(IText)
Declaration
public IText AddText(IText text)
Parameters
| Type |
Name |
Description |
| IText |
text |
|
Returns
AddText(String)
Declaration
public IText AddText(string text)
Parameters
| Type |
Name |
Description |
| System.String |
text |
|
Returns
Clone()
Declaration
public override IContentElement Clone()
Returns
Overrides
SetAlignment(TextAlignment)
Declaration
public IParagraph SetAlignment(TextAlignment alignment)
Parameters
Returns
SetStyle(IParagraphStyle)
Declaration
public IParagraph SetStyle(IParagraphStyle style)
Parameters
Returns
Implements