GemBox.Presentation is a .NET component that enables you to read, write, edit, convert, and print presentation files from your .NET applications using one simple API.

Text Box Formatting

GemBox.Presentation supports text box-formatting options like vertical alignment, text direction, auto-fit and many others.

The following example shows some of the available text box-formatting options.

Screenshot
Text Box Formatting Screenshot

See the full code below, use Run Example to execute.

using GemBox.Presentation;

class Sample
{
    [STAThread]
    static void Main(string[] args)
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        PresentationDocument presentation = new PresentationDocument();

        // Create new slide.
        Slide slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Create new text box.
        TextBox textBox = slide.Content.AddTextBox(
            ShapeGeometryType.RoundedRectangle, 2, 2, 10, 10, LengthUnit.Centimeter);

        // Set shape format.
        textBox.Shape.Format.Fill.SetSolid(Color.FromName(ColorName.LightGray));
        textBox.Shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.DarkGray));
        textBox.Shape.Format.Outline.Width = Length.From(1, LengthUnit.Point);

        // Set text box text.
        textBox.AddParagraph().AddRun("Shows some of the text box formatting options available in GemBox.Presentation component.");

        // Get text box format.
        TextBoxFormat format = textBox.Format;

        // Set vertical alignment of the text.
        format.VerticalAlignment = VerticalAlignment.Middle;

        // Set left and top margin.
        format.InternalMarginLeft = Length.From(1, LengthUnit.Centimeter);
        format.InternalMarginTop = Length.From(1, LengthUnit.Centimeter);

        // Set text direction.
        format.TextDirection = TextDirection.Rotate270;

        // Wrap text in shape.
        format.WrapText = true;

        presentation.Save("Text Box Formatting.pptx");
    }
}
Imports GemBox.Presentation

Module Samples

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        Dim presentation As PresentationDocument = New PresentationDocument

        ' Create new slide.
        Dim slide As Slide = presentation.Slides.AddNew(SlideLayoutType.Custom)

        ' Create new text box.
        Dim textBox As TextBox = slide.Content.AddTextBox(
            ShapeGeometryType.RoundedRectangle, 2, 2, 10, 10, LengthUnit.Centimeter)

        ' Set shape format.
        textBox.Shape.Format.Fill.SetSolid(Color.FromName(ColorName.LightGray))
        textBox.Shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.DarkGray))
        textBox.Shape.Format.Outline.Width = Length.From(1, LengthUnit.Point)

        ' Set text box text.
        textBox.AddParagraph().AddRun("Shows some of the text box formatting options available in GemBox.Presentation component.")

        ' Get text box format.
        Dim format As TextBoxFormat = textBox.Format

        ' Set vertical alignment of the text.
        format.VerticalAlignment = VerticalAlignment.Middle

        ' Set left And top margin.
        format.InternalMarginLeft = Length.From(1, LengthUnit.Centimeter)
        format.InternalMarginTop = Length.From(1, LengthUnit.Centimeter)

        ' Set text direction.
        format.TextDirection = TextDirection.Rotate270

        ' Wrap text in shape.
        format.WrapText = True

        presentation.Save("Text Box Formatting.pptx")

    End Sub

End Module

Check next sample.