幻灯片的中文字默认是横向排列,用户可以通过更改文字方向使其竖向排列、面向左边缘排列或者面向右边缘排列。本文将展示如何使用Spire.Presentation更改幻灯片中文字的方向。
C#
//初始化Presentation实例
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 = "欢迎光临";
//设置文字方向为东亚竖排(避免文字旋转90度)
textboxShape.TextFrame.VerticalTextType = VerticalTextType.EastAsianVertical;
//保存文档
ppt.SaveToFile("output.pptx", FileFormat.Pptx2013);
VB.NET
'初始化Presentation实例
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 = "欢迎光临"
'设置文字方向为东亚竖排(避免文字旋转90度)
textboxShape.TextFrame.VerticalTextType = VerticalTextType.EastAsianVertical
'保存文档
ppt.SaveToFile("output.pptx", FileFormat.Pptx2013)