Interface IParagraphs
Represents a collection of IParagraph instance in a ITextBody.
Inherited Members
Namespace: Syncfusion.Presentation
Assembly: Syncfusion.Presentation.Base.dll
Syntax
public interface IParagraphs : IEnumerable<IParagraph>, IEnumerable
Properties
Count
Gets the number of elements in the paragraph collection. Read-only.
Declaration
int Count { get; }
Property Value
Type |
---|
System.Int32 |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 350);
//Create instance to hold paragraph collection
IParagraphs paragraphs = shape.TextBody.Paragraphs;
//Add paragraph to collection; in turn add text part
paragraphs.Add().TextParts.Add("Lorem ipsum dolor sit amet");
//Create instance for paragraph
IParagraph paragraph = paragraphs.Add(", consectetur adipiscing elit");
//Get the paragraphs count, read only
int count = paragraphs.Count;
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 350)
'Create instance to hold paragraph collection
Dim paragraphs As IParagraphs = shape.TextBody.Paragraphs
'Add paragraph to collection; in turn add text part
paragraphs.Add().TextParts.Add("Lorem ipsum dolor sit amet")
'Create instance for paragraph
Dim paragraph As IParagraph = paragraphs.Add(", consectetur adipiscing elit")
'Get the paragraphs count, read only
Dim count As Integer = paragraphs.Count
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
Item[Int32]
Gets a IParagraph instance at the specified index from the collection. Read-only.
Declaration
IParagraph this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Determines the index of the text part. |
Property Value
Type | Description |
---|---|
IParagraph | Returns an IParagraph instance. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 350);
//Create instance to hold paragraph collection
IParagraphs paragraphs = shape.TextBody.Paragraphs;
//Add paragraph to collection; in turn add text part
paragraphs.Add().TextParts.Add("Lorem ipsum dolor sit amet");
//Create instance for paragraph
IParagraph paragraph = paragraphs.Add(", consectetur adipiscing elit");
//Get the specific paragraph instance, read only
IParagraph paragraph1 = paragraphs[0];
// Set the hanging value
paragraph1.FirstLineIndent = 20;
//Set the list level as 1
paragraph1.IndentLevelNumber = 1;
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 350)
'Create instance to hold paragraph collection
Dim paragraphs As IParagraphs = shape.TextBody.Paragraphs
'Add paragraph to collection; in turn add text part
paragraphs.Add().TextParts.Add("Lorem ipsum dolor sit amet")
'Create instance for paragraph
Dim paragraph As IParagraph = paragraphs.Add(", consectetur adipiscing elit")
'Get the specific paragraph instance, read only
Dim paragraph1 As IParagraph = paragraphs(0)
' Set the hanging value
paragraph1.FirstLineIndent = 20
'Set the list level as 1
paragraph1.IndentLevelNumber = 1
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
Methods
Add()
Adds a paragraph at the end of the paragraph collection.
Declaration
IParagraph Add()
Returns
Type | Description |
---|---|
IParagraph | Returns an IParagraph instance. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 350);
//Create instance to hold paragraph collection
IParagraphs paragraphs = shape.TextBody.Paragraphs;
//Add paragraph to collection; in turn add text part
paragraphs.Add().TextParts.Add("Lorem ipsum dolor sit amet");
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 350)
'Create instance to hold paragraph collection
Dim paragraphs As IParagraphs = shape.TextBody.Paragraphs
'Add paragraph to collection; in turn add text part
paragraphs.Add().TextParts.Add("Lorem ipsum dolor sit amet")
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
Add(String)
Adds a paragraph with the specified text, at the end of the paragraph collection.
Declaration
IParagraph Add(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | Specifies the text content to add. |
Returns
Type | Description |
---|---|
IParagraph | Returns an IParagraph instance this method creates. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 350);
//Create instance to hold paragraph collection
IParagraphs paragraphs = shape.TextBody.Paragraphs;
//Add paragraph to collection
IParagraph paragraph = paragraphs.Add("Lorem ipsum dolor sit amet, consectetur adipiscing elit");
//Retrieve the paragraph font
IFont font = paragraph.Font;
//Set the font size
font.FontSize = 26;
//Set the horizontal alignment
paragraph.HorizontalAlignment = HorizontalAlignmentType.Justify;
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 350)
'Add paragraph to collection
Dim paragraph As IParagraph = paragraphs.Add("Lorem ipsum dolor sit amet, consectetur adipiscing elit")
'Retrieve the paragraph font
Dim font As IFont = paragraph.Font
'Set the font size
font.FontSize = 26
'Set the horizontal alignment
paragraph.HorizontalAlignment = HorizontalAlignmentType.Justify
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
Clear()
Removes all the elements from paragraph collection.
Declaration
void Clear()
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 350);
//Create instance to hold paragraph collection
IParagraphs paragraphs = shape.TextBody.Paragraphs;
//Add paragraph to collection; in turn add text part
paragraphs.Add().TextParts.Add("Lorem ipsum dolor sit amet");
//Add paragraph to paragraphs
paragraphs.Add("sed do eiusmod tempor incididunt");
paragraphs.Add("ut labore et dolore magna aliqua.");
//Clear the paragraph collection
paragraphs.Clear();
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 350)
'Create instance to hold paragraph collection
Dim paragraphs As IParagraphs = shape.TextBody.Paragraphs
'Add paragraph to collection; in turn add text part
paragraphs.Add().TextParts.Add("Lorem ipsum dolor sit amet")
'Add paragraph to paragraphs
paragraphs.Add("sed do eiusmod tempor incididunt")
paragraphs.Add("ut labore et dolore magna aliqua.")
'Clear the paragraph collection
paragraphs.Clear()
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
IndexOf(IParagraph)
Returns the zero-based index of the first occurrence of the IParagraph instance within the collection.
Declaration
int IndexOf(IParagraph item)
Parameters
Type | Name | Description |
---|---|---|
IParagraph | item | The IParagraph instance to locate in the collection. |
Returns
Type | Description |
---|---|
System.Int32 | Returns the zero-based index of the first occurrence of the paragraph within the collection, if found; otherwise, –1. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 350);
//Create instance to hold paragraph collection
IParagraphs paragraphs = shape.TextBody.Paragraphs;
//Add paragraph to collection; in turn add text part
paragraphs.Add().TextParts.Add("Lorem ipsum dolor sit amet");
//Create instance for paragraph
IParagraph paragraph = paragraphs.Add(", consectetur adipiscing elit");
//Get the index of specific paragraph instance
int index = paragraphs.IndexOf(paragraph);
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 350)
'Create instance to hold paragraph collection
Dim paragraphs As IParagraphs = shape.TextBody.Paragraphs
'Add paragraph to collection; in turn add text part
paragraphs.Add().TextParts.Add("Lorem ipsum dolor sit amet")
'Create instance for paragraph
Dim paragraph As IParagraph = paragraphs.Add(", consectetur adipiscing elit")
'Get the index of specific paragraph instance
Dim index As Integer = paragraphs.IndexOf(paragraph)
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
Insert(Int32, IParagraph)
Inserts a specific paragraph at the specific location of the paragraph collection.
Declaration
void Insert(int index, IParagraph value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | |
IParagraph | value |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 350);
//create instance for text body from shape
ITextBody textBody = shape.TextBody;
//Add first paragraph
IParagraph paragraph1 = textBody.AddParagraph();
//Add first text part to the paragraph
textBody.Paragraphs[0].AddTextPart("Add First Paragraph");
//Add second paragraph
IParagraph paragraph2 = textBody.AddParagraph();
//Add first text part to the paragraph
textBody.Paragraphs[1].AddTextPart("Add Second Paragraph");
//Add second paragraph
textBody.Paragraphs.Insert(0, textBody.Paragraphs[1]);
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 350)
'create instance for text body from shape
Dim textBody As ITextBody = shape.TextBody
'Add first paragraph
Dim paragraph1 As IParagraph = textBody.AddParagraph()
'Add first text part to the paragraph
textBody.Paragraphs(0).AddTextPart("Add First Paragraph")
'Add second paragraph
Dim paragraph2 As IParagraph = textBody.AddParagraph()
'Add first text part to the paragraph
textBody.Paragraphs(1).AddTextPart("Add Second Paragraph")
'Add second paragraph
textBody.Paragraphs.Insert(0, paragraph2)
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
Remove(IParagraph)
Removes the first occurrence of a specified IParagraph instance from the paragraph collection.
Declaration
void Remove(IParagraph item)
Parameters
Type | Name | Description |
---|---|---|
IParagraph | item | The paragraph instance to be removed from the collection. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 350);
//Create instance to hold paragraph collection
IParagraphs paragraphs = shape.TextBody.Paragraphs;
//Add paragraph to collection; in turn add text part
paragraphs.Add().TextParts.Add("Lorem ipsum dolor sit amet");
//Add paragraph to collection
IParagraph paragraph = paragraphs.Add(", consectetur adipiscing elit");
//Remove a specific paragraph instance
paragraphs.Remove(paragraph);
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 350)
'Create instance to hold paragraph collection
Dim paragraphs As IParagraphs = shape.TextBody.Paragraphs
'Add paragraph to collection; in turn add text part
paragraphs.Add().TextParts.Add("Lorem ipsum dolor sit amet")
'Add paragraph to collection
Dim paragraph As IParagraph = paragraphs.Add(", consectetur adipiscing elit")
'Remove a specific paragraph instance
paragraphs.Remove(paragraph)
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
RemoveAt(Int32)
Removes the IParagraph instance at the specified index of the paragraph collection.
Declaration
void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index of the element to be removed. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 350);
//Create instance to hold paragraph collection
IParagraphs paragraphs = shape.TextBody.Paragraphs;
//Add paragraph to collection; in turn add text part
paragraphs.Add().TextParts.Add("Lorem ipsum dolor sit amet");
//Add paragraph to collection
IParagraph paragraph = paragraphs.Add(", consectetur adipiscing elit");
//Remove paragraph at specific index
paragraphs.RemoveAt(0);
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 350)
'Create instance to hold paragraph collection
Dim paragraphs As IParagraphs = shape.TextBody.Paragraphs
'Add paragraph to collection; in turn add text part
paragraphs.Add().TextParts.Add("Lorem ipsum dolor sit amet")
'Add paragraph to collection
Dim paragraph As IParagraph = paragraphs.Add(", consectetur adipiscing elit")
'Remove paragraph at specific index
paragraphs.RemoveAt(0)
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()