幻灯片的中文字默认是横向排列,用户可以通过更改文字方向使其竖向排列、面向左边缘排列或者面向右边缘排列。本文将展示如何使用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)