How to Change Text Direction in PowerPoint in C#, VB.NET

You may sometimes want your text to display vertically (letters stacked one on top of the other), horizontally, or rotated facing the right margin or the left margin. This tutorial shows you how to change the text direction using VerticalTextType property in Spire.Presentation.

Step 1: Initialize an instance of Prensentation class.

Presentation ppt = new Presentation();

Step 2: Append a shape with text to the first slide.

IAutoShape textboxShape = ppt.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 70, 100, 400));
textboxShape.ShapeStyle.LineColor.Color = Color.Transparent;
textboxShape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
textboxShape.Fill.SolidColor.Color = Color.OrangeRed;
textboxShape.TextFrame.Text = "You Are Welcome Here";

Step 3: Set the text direction to vertical.

textboxShape.TextFrame.VerticalTextType = VerticalTextType.Vertical;

Step 4: Append another shape with text to the slide.

textboxShape = ppt.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(150, 70, 100, 400));
textboxShape.ShapeStyle.LineColor.Color = Color.Transparent;
textboxShape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
textboxShape.Fill.SolidColor.Color = Color.Orange;
textboxShape.TextFrame.Text = "欢迎光临";

Step 5: For asian characters, you can set the VerticalTextType as EastAsianVertical to aviod rotating text 90 degrees.

textboxShape.TextFrame.VerticalTextType = VerticalTextType.EastAsianVertical;

Step 6: Save the file.

ppt.SaveToFile("output.pptx", FileFormat.Pptx2013);

Output:

How to Change Text Direction in PowerPoint in C#, VB.NET

Full Code:

[C#]
using Spire.Presentation;
using System.Drawing;
namespace ChangeTextDirection
{
    class Program
    {
        static void Main(string[] args)
        {

            Presentation ppt = new Presentation();

            IAutoShape textboxShape = ppt.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 70, 100, 400));
            textboxShape.ShapeStyle.LineColor.Color = Color.Transparent;
            textboxShape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
            textboxShape.Fill.SolidColor.Color = Color.OrangeRed;
            textboxShape.TextFrame.Text = "You Are Welcome Here";
            textboxShape.TextFrame.VerticalTextType = VerticalTextType.Vertical;

            textboxShape = ppt.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(150, 70, 100, 400));
            textboxShape.ShapeStyle.LineColor.Color = Color.Transparent;
            textboxShape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
            textboxShape.Fill.SolidColor.Color = Color.Orange;
            textboxShape.TextFrame.Text = "欢迎光临";
            textboxShape.TextFrame.VerticalTextType = VerticalTextType.EastAsianVertical;

            ppt.SaveToFile("output.pptx", FileFormat.Pptx2013);

        }
    }
}
[VB.NET]
Imports Spire.Presentation
Imports System.Drawing
Namespace ChangeTextDirection
	Class Program
		Private Shared Sub Main(args As String())

			Dim ppt As New Presentation()

			Dim textboxShape As IAutoShape = ppt.Slides(0).Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(50, 70, 100, 400))
			textboxShape.ShapeStyle.LineColor.Color = Color.Transparent
			textboxShape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid
			textboxShape.Fill.SolidColor.Color = Color.OrangeRed
			textboxShape.TextFrame.Text = "You Are Welcome Here"
			textboxShape.TextFrame.VerticalTextType = VerticalTextType.Vertical

			textboxShape = ppt.Slides(0).Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(150, 70, 100, 400))
			textboxShape.ShapeStyle.LineColor.Color = Color.Transparent
			textboxShape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid
			textboxShape.Fill.SolidColor.Color = Color.Orange
			textboxShape.TextFrame.Text = "欢迎光临"
			textboxShape.TextFrame.VerticalTextType = VerticalTextType.EastAsianVertical

			ppt.SaveToFile("output.pptx", FileFormat.Pptx2013)

		End Sub
	End Class
End Namespace