menu

Xamarin.Forms

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Interface ITextBody - Xamarin.Forms API Reference | Syncfusion

    Show / Hide Table of Contents

    Interface ITextBody

    Represents the alignment and anchoring of the text.

    Namespace: Syncfusion.Presentation
    Assembly: Syncfusion.Presentation.Portable.dll
    Syntax
    public interface ITextBody

    Properties

    AnchorCenter

    Gets or sets a boolean value indicates whether to anchor center with the vertical alignment.

    Declaration
    bool AnchorCenter { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if [anchor center]; otherwise, false.

    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");
    //Set anchor center to the textBody 
    textBody.AnchorCenter = true;
    //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")
    'Set anchor center to the textBody 
    textBody.AnchorCenter = True
    'Save the presentation
    presentation__1.Save("Sample.pptx")
    'Close the presentation
    presentation__1.Close()

    MarginBottom

    Gets or sets the distance between the bottom of the text body and the bottom of the rectangle shape that contains the text, in points. Value ranges from 1 to 1583.

    Declaration
    double MarginBottom { get; set; }
    Property Value
    Type Description
    System.Double

    The margin bottom of the TextBody.

    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");
    //Set the Margin bottom
    textBody.MarginBottom = 100;
    //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")
    'Set the Margin bottom
    textBody.MarginBottom = 100
    'Save the presentation
    presentation__1.Save("Sample.pptx")
    'Close the presentation
    presentation__1.Close()

    MarginLeft

    Gets or sets the distance between the left edge of the text body and the left edge of the rectangle shape that contains the text, in points. Value ranges from 1 to 1583.

    Declaration
    double MarginLeft { get; set; }
    Property Value
    Type Description
    System.Double

    The margin left of the TextBody.

    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");
    //Set the Margin left
    textBody.MarginLeft = 150;
    //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")
    'Set the Margin left
    textBody.MarginLeft = 130
    'Save the presentation
    presentation__1.Save("Sample.pptx")
    'Close the presentation
    presentation__1.Close()

    MarginRight

    Gets or sets the distance between the right edge of the text body and the right edge of the rectangle shape that contains the text, in points. Value ranges from 1 to 1583.

    Declaration
    double MarginRight { get; set; }
    Property Value
    Type Description
    System.Double

    The margin right of the TextBody.

    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");
    //Set the Margin right
    textBody.MarginRight = 50;
    //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")
    'Set the Margin right
    textBody.MarginRight = 160
    'Save the presentation
    presentation__1.Save("Sample.pptx")
    'Close the presentation
    presentation__1.Close()

    MarginTop

    Gets or sets the distance between the top of the text body and the top of the rectangle shape that contains the text, in points. Value ranges from 1 to 1583.

    Declaration
    double MarginTop { get; set; }
    Property Value
    Type Description
    System.Double

    The margin top of the TextBody.

    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");
    //Set the Margin top
    textBody.MarginTop = 140;
    //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")
    'Set the Margin Top
    textBody.MarginTop = 200
    'Save the presentation
    presentation__1.Save("Sample.pptx")
    'Close the presentation
    presentation__1.Close()

    Paragraphs

    Gets an IParagraphs instance that represents the paragraph collection. Read-only.

    Declaration
    IParagraphs Paragraphs { get; }
    Property Value
    Type Description
    IParagraphs

    The paragraphs object of the TextBody.

    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");
    //Retrieve the paragraph from text body
    IParagraph paragraph = textBody.Paragraphs[0];
    //Add second text part to the first paragraph
    paragraph.AddTextPart().Text = ",2nd text part in 1st 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 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")
    'Retrieve the paragraph from text body
    Dim paragraph As IParagraph = textBody.Paragraphs(0)
    'Add second text part to the first paragraph
    paragraph.AddTextPart().Text = ",2nd text part in 1st paragraph"
    'Save the presentation
    presentation__1.Save("Sample.pptx")
    'Close the presentation
    presentation__1.Close()

    Text

    Gets the text content of the text body.

    Declaration
    string Text { get; set; }
    Property Value
    Type Description
    System.String

    The text of the TextBody.

    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");
    //Get the text of text body, read only
    string text = textBody.Text;
    //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")
    'Get the text of text body, read only
    Dim text As String = textBody.Text
    'Save the presentation
    presentation__1.Save("Sample.pptx")
    'Close the presentation
    presentation__1.Close()

    TextDirection

    Gets or sets the text direction.

    Declaration
    TextDirectionType TextDirection { get; set; }
    Property Value
    Type Description
    TextDirectionType

    The text direction type of the TextBody.

    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");
    //Set the text direction
    textBody.TextDirection = TextDirectionType.Horizontal;
    //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")
    'Set the text direction
    textBody.TextDirection = TextDirectionType.Horizontal
    'Save the presentation
    presentation__1.Save("Sample.pptx")
    'Close the presentation
    presentation__1.Close()

    VerticalAlignment

    Gets or sets the vertical alignment of text in a text body.

    Declaration
    VerticalAlignmentType VerticalAlignment { get; set; }
    Property Value
    Type Description
    VerticalAlignmentType

    The vertical alignment type of the TextBody.

    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");
    //Retrieve the paragraph from text body
    IParagraph paragraph = textBody.Paragraphs[0];
    //Add second text part to the first paragraph
    paragraph.AddTextPart().Text = ",2nd text part in 1st paragraph";
    //Set vertical alignment
    textBody.VerticalAlignment = VerticalAlignmentType.Middle;
    //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")
    'Retrieve the paragraph from text body
    Dim paragraph As IParagraph = textBody.Paragraphs(0)
    'Add second text part to the first paragraph
    paragraph.AddTextPart().Text = ",2nd text part in 1st paragraph"
    'Set vertical alignment
    textBody.VerticalAlignment = VerticalAlignmentType.Middle
    'Save the presentation
    presentation__1.Save("Sample.pptx")
    'Close the presentation
    presentation__1.Close()

    WrapText

    Gets or sets a boolean value indicates whether lines break automatically to fit inside the shape.

    Declaration
    bool WrapText { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if [wrap text]; otherwise, false.

    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");
    //Retrieve the paragraph from text body
    IParagraph paragraph = textBody.Paragraphs[0];
    //Add second text part to the first paragraph
    paragraph.AddTextPart().Text = ",2nd text part in 1st paragraph";
    //Set wrap text to fit the text within shape
    textBody.WrapText = true;
    //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")
    'Retrieve the paragraph from text body
    Dim paragraph As IParagraph = textBody.Paragraphs(0)
    'Add second text part to the first paragraph
    paragraph.AddTextPart().Text = ",2nd text part in 1st paragraph"
    'Set wrap text to fit the text within shape
    textBody.WrapText = True
    'Save the presentation
    presentation__1.Save("Sample.pptx")
    'Close the presentation
    presentation__1.Close()

    Methods

    AddParagraph()

    Adds a paragraph at the end of the paragraph collection.

    Declaration
    IParagraph AddParagraph()
    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 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");   
    //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")
    'Save the presentation
    presentation__1.Save("Sample.pptx")
    'Close the presentation
    presentation__1.Close()

    AddParagraph(String)

    Adds a paragraph at the end of the collection.

    Declaration
    IParagraph AddParagraph(string text)
    Parameters
    Type Name Description
    System.String text

    Represents the text content.

    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 for text body from shape
    ITextBody textBody = shape.TextBody;
    //Add first paragraph
    IParagraph paragraph1 = textBody.AddParagraph("Add First 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 for text body from shape
    Dim textBody As ITextBody = shape.TextBody
    'Add first paragraph
    Dim paragraph1 As IParagraph = textBody.AddParagraph("Add First Paragraph")
    'Save the presentation
    presentation__1.Save("Sample.pptx")
    'Close the presentation
    presentation__1.Close()
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved